MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / utf16ToString

Function utf16ToString

source/core/StarString_windows.cpp:14–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14String utf16ToString(WCHAR const* s) {
15 if (!s)
16 return "";
17 int sLen = wcharLen(s);
18 int utf8Len = WideCharToMultiByte(CP_UTF8, 0, s, sLen + 1, NULL, 0, NULL, NULL);
19 auto utf8Buffer = new char[utf8Len];
20 WideCharToMultiByte(CP_UTF8, 0, s, sLen + 1, utf8Buffer, utf8Len, NULL, NULL);
21 auto result = String(utf8Buffer, utf8Len - 1);
22 delete[] utf8Buffer;
23 return result;
24}
25
26unique_ptr<WCHAR[]> stringToUtf16(String const& s) {
27 int utf16Len = MultiByteToWideChar(CP_UTF8, 0, s.utf8Ptr(), s.utf8Size() + 1, NULL, 0);

Callers 6

netErrorStringFunction · 0.85
currentDirectoryMethod · 0.85
fullPathMethod · 0.85
dirListMethod · 0.85
temporaryFileNameMethod · 0.85
temporaryDirectoryMethod · 0.85

Calls 2

wcharLenFunction · 0.85
StringClass · 0.85

Tested by

no test coverage detected