| 60 | #ifdef _WIN32 |
| 61 | |
| 62 | std::string to_utf8(const std::wstring& src) |
| 63 | { |
| 64 | int required_size = |
| 65 | ::WideCharToMultiByte(CP_UTF8, 0, |
| 66 | src.c_str(), (int)src.size(), |
| 67 | NULL, 0, NULL, NULL); |
| 68 | |
| 69 | if (required_size == 0) |
| 70 | return std::string(); |
| 71 | |
| 72 | std::vector<char> buf(++required_size); |
| 73 | |
| 74 | ::WideCharToMultiByte(CP_UTF8, 0, |
| 75 | src.c_str(), (int)src.size(), |
| 76 | &buf[0], required_size, |
| 77 | NULL, NULL); |
| 78 | |
| 79 | return std::string(&buf[0]); |
| 80 | } |
| 81 | |
| 82 | std::wstring from_utf8(const std::string& src) |
| 83 | { |