MCPcopy Create free account
hub / github.com/WinMerge/winmerge / LCMapStringAuto

Function LCMapStringAuto

Src/Common/unicoder.cpp:1384–1419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382using LCMapStringEx_t = int (WINAPI*)(LPCWSTR lpLocaleName, DWORD dwMapFlags, LPCWSTR lpSrcStr, int cchSrc, LPWSTR lpDestStr, int cchDest, LPNLSVERSIONINFO lpVersionInformation, LPVOID lpReserved, LPARAM sortHandle);
1383
1384static String LCMapStringAuto(const String& input, unsigned mapFlags)
1385{
1386 if (input.empty())
1387 return input;
1388
1389 static LCMapStringEx_t pLCMapStringEx = nullptr;
1390 static bool checked = false;
1391
1392 if (!checked)
1393 {
1394 HMODULE hKernel32 = GetModuleHandleW(L"kernel32.dll");
1395 if (hKernel32)
1396 pLCMapStringEx = reinterpret_cast<LCMapStringEx_t>(GetProcAddress(hKernel32, "LCMapStringEx"));
1397 checked = true;
1398 }
1399
1400 if (pLCMapStringEx)
1401 {
1402 int len = pLCMapStringEx(nullptr, mapFlags, input.c_str(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr, 0);
1403 if (len <= 0)
1404 return input;
1405 std::wstring result(len, L'\0');
1406 pLCMapStringEx(nullptr, mapFlags, input.c_str(), static_cast<int>(input.size()), result.data(), len, nullptr, nullptr, 0);
1407 return result;
1408 }
1409
1410 // XP fallback
1411 int len = LCMapStringW(LOCALE_USER_DEFAULT, mapFlags, input.c_str(), static_cast<int>(input.size()), nullptr, 0);
1412 if (len <= 0)
1413 return input;
1414
1415 std::wstring result(len, L'\0');
1416 LCMapStringW(LOCALE_USER_DEFAULT, mapFlags, input.c_str(), static_cast<int>(input.size()), result.data(), len);
1417
1418 return result;
1419}
1420
1421String toUpper(const String& s)
1422{

Callers 8

toUpperFunction · 0.85
toLowerFunction · 0.85
toHalfWidthFunction · 0.85
toFullWidthFunction · 0.85
toKatakanaFunction · 0.85
toHiraganaFunction · 0.85
toSimplifiedChineseFunction · 0.85
toTraditionalChineseFunction · 0.85

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected