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

Method AssignStringToCodePage

source/var.cpp:1265–1290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1263
1264
1265ResultType Var::AssignStringToCodePage(LPCWSTR aBuf, int aLength, UINT aCodePage, DWORD aFlags, char aDefChar)
1266{
1267 char *pDefChar;
1268 if (aCodePage == CP_UTF8 || aCodePage == CP_UTF7) {
1269 pDefChar = NULL;
1270 aFlags = 0;
1271 }
1272 else
1273 pDefChar = &aDefChar;
1274 int iLen = WideCharToMultiByte(aCodePage, aFlags, aBuf, aLength, NULL, 0, pDefChar, NULL);
1275 if (iLen > 0) {
1276 if (!SetCapacity(iLen, true))
1277 return FAIL;
1278 LPSTR aContents = (LPSTR) Contents(TRUE);
1279 iLen = WideCharToMultiByte(aCodePage, aFlags, aBuf, aLength, aContents, iLen, pDefChar, NULL);
1280 aContents[iLen] = 0;
1281 if (!iLen)
1282 return FAIL;
1283#ifndef UNICODE
1284 SetCharLength(aContents[iLen - 1] ? iLen : iLen - 1);
1285#endif
1286 }
1287 else
1288 Assign();
1289 return OK;
1290}
1291
1292
1293

Callers

nothing calls this directly

Calls 1

SetCapacityFunction · 0.85

Tested by

no test coverage detected