MCPcopy Create free account
hub / github.com/apache/singa / AnsiToUtf16

Method AnsiToUtf16

test/gtest/gtest-all.cc:2324–2335  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

2322// value using delete[]. Returns the wide string, or NULL if the
2323// input is NULL.
2324LPCWSTR String::AnsiToUtf16(const char* ansi) {
2325 if (!ansi) return NULL;
2326 const int length = strlen(ansi);
2327 const int unicode_length =
2328 MultiByteToWideChar(CP_ACP, 0, ansi, length,
2329 NULL, 0);
2330 WCHAR* unicode = new WCHAR[unicode_length + 1];
2331 MultiByteToWideChar(CP_ACP, 0, ansi, length,
2332 unicode, unicode_length);
2333 unicode[unicode_length] = 0;
2334 return unicode;
2335}
2336
2337// Creates an ANSI string from the given wide string, allocating
2338// memory using new. The caller is responsible for deleting the return

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected