MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / AnsiToUtf16

Method AnsiToUtf16

tests/gtest/gtest-all.cc:2364–2374  ·  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

2362// value using delete[]. Returns the wide string, or NULL if the
2363// input is NULL.
2364LPCWSTR 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected