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

Method convertUtf16ToUtf8

astyle/src/astyle_main.cpp:2639–2649  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2637 * allocated memory.
2638 */
2639char* ASLibrary::convertUtf16ToUtf8(const wchar_t* wcharIn) const
2640{
2641 int utf8Len = WideCharToMultiByte(CP_UTF8, 0, wcharIn, -1, 0, 0, 0, 0);
2642 if (utf8Len == 0)
2643 return NULL;
2644 char* utf8 = new(nothrow) char[utf8Len];
2645 if (utf8 == NULL)
2646 return NULL;
2647 WideCharToMultiByte(CP_UTF8, 0, wcharIn, -1, utf8, utf8Len, 0, 0);
2648 return utf8;
2649}
2650
2651#else // not _WIN32
2652

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected