| 78 | const std::string dummy; |
| 79 | |
| 80 | static std::string WideToUtf8(const wchar_t *in) { |
| 81 | if (nullptr == in) { |
| 82 | return dummy; |
| 83 | } |
| 84 | int size = WideCharToMultiByte(CP_UTF8, 0, in, -1, nullptr, 0, nullptr, nullptr); |
| 85 | // size includes terminating null; std::string adds null automatically |
| 86 | std::string out(static_cast<size_t>(size) - 1, '\0'); |
| 87 | WideCharToMultiByte(CP_UTF8, 0, in, -1, &out[0], size, nullptr, nullptr); |
| 88 | |
| 89 | return out; |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | // ------------------------------------------------------------------------------------------------ |