| 8 | #include <wil/resource.h> |
| 9 | |
| 10 | std::string sfh::WideToUtf8String(const std::wstring& wStr) |
| 11 | { |
| 12 | std::string ret; |
| 13 | const int length = WideCharToMultiByte( |
| 14 | CP_UTF8, |
| 15 | WC_ERR_INVALID_CHARS, |
| 16 | wStr.c_str(), |
| 17 | static_cast<int>(wStr.size()), |
| 18 | nullptr, |
| 19 | 0, |
| 20 | nullptr, |
| 21 | nullptr); |
| 22 | assert(length != 0 && "wide char conversion to utf8 mustn't fail!"); |
| 23 | ret.resize(length); |
| 24 | WideCharToMultiByte( |
| 25 | CP_UTF8, |
| 26 | WC_ERR_INVALID_CHARS, |
| 27 | wStr.c_str(), |
| 28 | static_cast<int>(wStr.size()), |
| 29 | ret.data(), |
| 30 | length, |
| 31 | nullptr, |
| 32 | nullptr); |
| 33 | return ret; |
| 34 | } |
| 35 | |
| 36 | std::wstring sfh::Utf8ToWideString(const std::string& str) |
| 37 | { |
nothing calls this directly
no outgoing calls
no test coverage detected