MCPcopy Create free account
hub / github.com/dirkvranckaert/AndroidDecompiler / convertUtf8ToUtf16

Method convertUtf8ToUtf16

astyle/src/astyle_main.cpp:2621–2631  ·  view source on GitHub ↗

* WINDOWS function to convert utf-8 strings to wchar_t (utf16) strings. * Windows wchar_t is utf-16. * Memory is allocated by the calling program memory allocation function. * The calling function must check for errors. */

Source from the content-addressed store, hash-verified

2619 * The calling function must check for errors.
2620 */
2621wchar_t* ASLibrary::convertUtf8ToUtf16(const char* utf8In, fpAlloc fpMemoryAlloc) const
2622{
2623 int wideLen = MultiByteToWideChar(CP_UTF8, 0, utf8In, -1, 0, 0);
2624 if (wideLen == 0)
2625 return NULL;
2626 wchar_t* wide = reinterpret_cast<wchar_t*>(fpMemoryAlloc(wideLen * 2));
2627 if (wide == NULL)
2628 return NULL;
2629 MultiByteToWideChar(CP_UTF8, 0, utf8In, -1, wide, wideLen);
2630 return wide;
2631}
2632
2633/**
2634 * WINDOWS function to convert wchar_t (utf16) strings to utf-8 strings.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected