-------------------------------------------------------------------------
| 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 | //----------------------------------------------------------------------------- |
no outgoing calls
no test coverage detected