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

Function StringWCharToChar

source/StringConv.cpp:63–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63LPCSTR StringWCharToChar(LPCWSTR sWChar, CStringA &sChar, int iChars/* = -1*/, char chDef/* = '?'*/, UINT codepage/* = CP_ACP*/)
64{
65 if (!sWChar)
66 return NULL;
67
68 sChar.Empty();
69 int iLen = WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, sWChar, iChars, NULL, 0, &chDef, NULL);
70 if (iLen > 0) {
71 LPSTR sBuf = sChar.GetBufferSetLength(iLen);
72 WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, sWChar, iChars, sBuf, iLen, &chDef, NULL);
73 sChar.ReleaseBufferSetLength(sBuf[iLen - 1] ? iLen : iLen - 1);
74 return (iLen > 0) ? sChar.GetString() : NULL;
75 }
76
77 return (*sWChar != 0) ? sChar.GetString() : NULL;
78}
79
80LPCSTR StringUTF8ToChar(LPCSTR sUTF8, CStringA &sChar, int iChars/* = -1*/, char chDef/* = '?'*/, UINT codepage/* = CP_ACP*/)
81{

Callers 3

CStringCharFromWCharMethod · 0.85
StringUTF8ToCharFunction · 0.85
LoadStringMethod · 0.85

Calls 2

GetBufferSetLengthMethod · 0.80
GetStringMethod · 0.80

Tested by

no test coverage detected