MCPcopy Create free account
hub / github.com/OpenCppCoverage/OpenCppCoverage / ToWString

Function ToWString

Tools/Tool.cpp:67–83  ·  view source on GitHub ↗

-------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

65
66 //-------------------------------------------------------------------------
67 std::wstring ToWString(unsigned int pageCode, const std::string& str)
68 {
69 if (str.empty())
70 return{};
71
72 auto size = MultiByteToWideChar(pageCode, 0,
73 str.c_str(), static_cast<int>(str.size()), nullptr, 0);
74 std::vector<wchar_t> buffer(size);
75
76 if (!MultiByteToWideChar(pageCode, 0, str.c_str(), static_cast<int>(str.size()),
77 &buffer[0], static_cast<int>(buffer.size())))
78 {
79 throw std::runtime_error("Error in MultiByteToWideChar for " + str);
80 }
81
82 return{ buffer.begin(), buffer.end() };
83 }
84 }
85
86 //-----------------------------------------------------------------------------

Callers 2

LocalToWStringFunction · 0.70
Utf8ToWStringFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected