| 201 | |
| 202 | #ifdef _WIN32 |
| 203 | static std::wstring CPToUTF16(u32 code_page, std::string_view input) { |
| 204 | const auto size = |
| 205 | MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0); |
| 206 | |
| 207 | if (size == 0) { |
| 208 | return {}; |
| 209 | } |
| 210 | |
| 211 | std::wstring output(size, L'\0'); |
| 212 | |
| 213 | if (size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), |
| 214 | &output[0], static_cast<int>(output.size()))) { |
| 215 | output.clear(); |
| 216 | } |
| 217 | |
| 218 | return output; |
| 219 | } |
| 220 | |
| 221 | std::string UTF16ToUTF8(std::wstring_view input) { |
| 222 | const auto size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), |
no test coverage detected