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

Function ToString

Tools/Tool.cpp:48–64  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

46
47 //-------------------------------------------------------------------------
48 std::string ToString(unsigned int pageCode, const std::wstring& str)
49 {
50 if (str.empty())
51 return{};
52
53 auto size = WideCharToMultiByte(pageCode, 0, str.c_str(),
54 static_cast<int>(str.size()), nullptr, 0, nullptr, nullptr);
55 std::vector<char> buffer(size);
56
57 if (!WideCharToMultiByte(pageCode, 0, str.c_str(), static_cast<int>(str.size()),
58 &buffer[0], static_cast<int>(buffer.size()), nullptr, nullptr))
59 {
60 throw std::runtime_error("Error in WideCharToMultiByte.");
61 }
62
63 return{ buffer.begin(), buffer.end() };
64 }
65
66 //-------------------------------------------------------------------------
67 std::wstring ToWString(unsigned int pageCode, const std::string& str)

Callers 2

ToLocalStringFunction · 0.70
ToUtf8StringFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected