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