MCPcopy Create free account
hub / github.com/MyGUI/mygui / utf16_to_utf8

Function utf16_to_utf8

Wrappers/MyGUI_Managed/Utility.cpp:15–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13{
14
15 std::string utf16_to_utf8(const std::wstring& _source)
16 {
17 const wchar_t* srcPtr = _source.c_str();
18 int dstSize = WideCharToMultiByte( CP_UTF8, 0, srcPtr, (int)_source.size(), 0, 0, 0, 0 );
19 char* dest = new char [ dstSize + 1 ];
20 WideCharToMultiByte( CP_UTF8, 0, srcPtr, (int)_source.size(), dest, dstSize, 0, 0 );
21 dest[dstSize] = 0;
22 std::string ret = dest;
23 delete [] dest;
24 return ret;
25 }
26
27 std::string utf16_to_ansi(const std::wstring& _source)
28 {

Callers 1

Utility.hFile · 0.85

Calls 2

c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected