| 141 | } |
| 142 | |
| 143 | std::string StringUtils::FromWideString(const std::wstring &wide_string) { |
| 144 | if(wide_string.empty()) |
| 145 | return ""; |
| 146 | const auto size_needed = WideCharToMultiByte(CP_UTF8, 0, &wide_string.at(0), static_cast<int>(wide_string.size()), nullptr, 0, nullptr, nullptr); |
| 147 | if(size_needed <= 0) |
| 148 | return ""; |
| 149 | std::string result(size_needed, 0); |
| 150 | WideCharToMultiByte(CP_UTF8, 0, &wide_string.at(0), static_cast<int>(wide_string.size()), &result.at(0), size_needed, nullptr, nullptr); |
| 151 | return result; |
| 152 | } |
| 153 | #endif |