Converting UTF-8 to UTF-16
| 49 | #if defined(_WIN32) |
| 50 | /// Converting UTF-8 to UTF-16 |
| 51 | wchar_t* UTF8toUTF16(const char* utf8) { |
| 52 | if (utf8 == nullptr) return nullptr; |
| 53 | int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, nullptr, 0); |
| 54 | if (len <= 0) return nullptr; |
| 55 | wchar_t* utf16 = new wchar_t[len]; |
| 56 | MultiByteToWideChar(CP_UTF8, 0, utf8, -1, utf16, len); |
| 57 | return utf16; |
| 58 | } |
| 59 | |
| 60 | /// Converting ANSI to UTF-16 |
| 61 | wchar_t* ANSItoUTF16(const char* ansi) { |