| 166 | |
| 167 | #ifdef _WIN32 |
| 168 | static std::wstring CPToUTF16(u32 code_page, const std::string& input) { |
| 169 | const auto size = |
| 170 | MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0); |
| 171 | |
| 172 | if (size == 0) { |
| 173 | return {}; |
| 174 | } |
| 175 | |
| 176 | std::wstring output(size, L'\0'); |
| 177 | |
| 178 | if (size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), |
| 179 | &output[0], static_cast<int>(output.size()))) { |
| 180 | output.clear(); |
| 181 | } |
| 182 | |
| 183 | return output; |
| 184 | } |
| 185 | |
| 186 | std::string UTF16ToUTF8(const std::wstring& input) { |
| 187 | const auto size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), |
no test coverage detected