MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / ToWString

Function ToWString

src/shared/util.cpp:78–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78std::wstring ToWString(const std::string& source, bool utf8)
79{
80 std::wstring result;
81 if (source.length() > 0) {
82 UINT codepage = CP_UTF8;
83 if (!utf8) {
84 codepage = AreFileApisANSI() ? GetACP() : GetOEMCP();
85 }
86 int sizeRequired = ::MultiByteToWideChar(
87 codepage, 0, source.c_str(), static_cast<int>(source.length()), nullptr, 0);
88 if (sizeRequired == 0) {
89 throw windows_error("failed to convert string to wide character");
90 }
91 result.resize(sizeRequired, L'\0');
92 ::MultiByteToWideChar(codepage, 0, source.c_str(),
93 static_cast<int>(source.length()), &result[0], sizeRequired);
94 }
95
96 return result;
97}
98
99static std::locale loc("");
100static auto locToLowerW = [](wchar_t in) -> wchar_t {

Callers 15

displayModInformationMethod · 0.85
restoreHiddenFilesMethod · 0.85
getDescriptionMethod · 0.85
readTreeMethod · 0.85
createTweakedIniFileMethod · 0.85
mergeTweakMethod · 0.85
dataMethod · 0.85
modRenamedMethod · 0.85
fileMovedMethod · 0.85
extractBSATriggeredMethod · 0.85
refreshMethod · 0.85
saveLoadOrderMethod · 0.85

Calls 1

windows_errorClass · 0.85

Tested by

no test coverage detected