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

Function StringCharToWChar

source/StringConv.cpp:24–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24LPCWSTR StringCharToWChar(LPCSTR sChar, CStringW &sWChar, int iChars/* = -1*/, UINT codepage/* = CP_ACP*/)
25{
26 if (!sChar)
27 return NULL;
28
29 sWChar.Empty();
30 int iLen = MultiByteToWideChar(codepage, 0, sChar, iChars, NULL, 0);
31 if (iLen > 0) {
32 LPWSTR sBuf = sWChar.GetBufferSetLength(iLen);
33 MultiByteToWideChar(codepage, 0, sChar, iChars, sBuf, iLen);
34 sWChar.ReleaseBufferSetLength(sBuf[iLen - 1] ? iLen : iLen - 1);
35 return (iLen > 0) ? sWChar.GetString() : NULL;
36 }
37
38 return (*sChar != 0) ? sWChar.GetString() : NULL;
39}
40
41LPCSTR StringWCharToUTF8(LPCWSTR sWChar, CStringA &sUTF8, int iChars/* = -1*/)
42{

Callers 2

CStringWCharFromCharMethod · 0.85
BIF_DECLFunction · 0.85

Calls 2

GetBufferSetLengthMethod · 0.80
GetStringMethod · 0.80

Tested by

no test coverage detected