| 12 | } |
| 13 | |
| 14 | String utf16ToString(WCHAR const* s) { |
| 15 | if (!s) |
| 16 | return ""; |
| 17 | int sLen = wcharLen(s); |
| 18 | int utf8Len = WideCharToMultiByte(CP_UTF8, 0, s, sLen + 1, NULL, 0, NULL, NULL); |
| 19 | auto utf8Buffer = new char[utf8Len]; |
| 20 | WideCharToMultiByte(CP_UTF8, 0, s, sLen + 1, utf8Buffer, utf8Len, NULL, NULL); |
| 21 | auto result = String(utf8Buffer, utf8Len - 1); |
| 22 | delete[] utf8Buffer; |
| 23 | return result; |
| 24 | } |
| 25 | |
| 26 | unique_ptr<WCHAR[]> stringToUtf16(String const& s) { |
| 27 | int utf16Len = MultiByteToWideChar(CP_UTF8, 0, s.utf8Ptr(), s.utf8Size() + 1, NULL, 0); |
no test coverage detected