MCPcopy Create free account
hub / github.com/Aleksoid1978/VideoRenderer / ConvertUtf8orAnsiToWide

Function ConvertUtf8orAnsiToWide

Source/Utils/StringUtil.cpp:85–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85std::wstring ConvertUtf8orAnsiToWide(const std::string_view sv)
86{
87 UINT codePage = CP_UTF8;
88 int count = MultiByteToWideChar(codePage, MB_ERR_INVALID_CHARS, sv.data(), (int)sv.length(), nullptr, 0);
89 if (count == 0) {
90 codePage = CP_ACP;
91 count = MultiByteToWideChar(codePage, 0, sv.data(), (int)sv.length(), nullptr, 0);
92 }
93 std::wstring wstr(count, 0);
94 MultiByteToWideChar(codePage, 0, sv.data(), (int)sv.length(), &wstr[0], count);
95 return wstr;
96}
97
98std::string ConvertWideToAnsi(const std::wstring_view wsv)
99{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected