Creates a UTF-16 wide string from the given ANSI string, allocating memory using new. The caller is responsible for deleting the return value using delete[]. Returns the wide string, or NULL if the input is NULL.
| 2362 | // value using delete[]. Returns the wide string, or NULL if the |
| 2363 | // input is NULL. |
| 2364 | LPCWSTR String::AnsiToUtf16(const char* ansi) { |
| 2365 | if (!ansi) return nullptr; |
| 2366 | const int length = strlen(ansi); |
| 2367 | const int unicode_length = |
| 2368 | MultiByteToWideChar(CP_ACP, 0, ansi, length, nullptr, 0); |
| 2369 | WCHAR* unicode = new WCHAR[unicode_length + 1]; |
| 2370 | MultiByteToWideChar(CP_ACP, 0, ansi, length, |
| 2371 | unicode, unicode_length); |
| 2372 | unicode[unicode_length] = 0; |
| 2373 | return unicode; |
| 2374 | } |
| 2375 | |
| 2376 | // Creates an ANSI string from the given wide string, allocating |
| 2377 | // memory using new. The caller is responsible for deleting the return |
nothing calls this directly
no outgoing calls
no test coverage detected