MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / StringUTF8ToWChar

Function StringUTF8ToWChar

source/StringConv.cpp:7–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5
6#ifdef _WIN32
7LPCWSTR StringUTF8ToWChar(LPCSTR sUTF8, CStringW &sWChar, int iChars/* = -1*/)
8{
9 if (!sUTF8)
10 return NULL;
11
12 sWChar.Empty();
13 int iLen = MultiByteToWideChar(CP_UTF8, 0, sUTF8, iChars, NULL, 0);
14 if (iLen > 0) {
15 LPWSTR sBuf = sWChar.GetBufferSetLength(iLen);
16 iLen = MultiByteToWideChar(CP_UTF8, 0, sUTF8, iChars, sBuf, iLen);
17 sWChar.ReleaseBufferSetLength(sBuf[iLen - 1] ? iLen : iLen - 1);
18 return (iLen > 0) ? sWChar.GetString() : NULL;
19 }
20
21 return *sUTF8 != 0 ? sWChar.GetString() : NULL;
22}
23
24LPCWSTR StringCharToWChar(LPCSTR sChar, CStringW &sWChar, int iChars/* = -1*/, UINT codepage/* = CP_ACP*/)
25{

Callers 3

StringUTF8ToTCharFunction · 0.85
CStringWCharFromUTF8Method · 0.85
CStringTCharFromUTF8Method · 0.85

Calls 2

GetBufferSetLengthMethod · 0.80
GetStringMethod · 0.80

Tested by

no test coverage detected