May throw exceptions
| 399 | |
| 400 | // May throw exceptions |
| 401 | static std::wstring UTF8ToWString(const std::string &str) { |
| 402 | std::wstring wstr; |
| 403 | wstr.resize(str.size()); |
| 404 | wstr.resize(utf8towc(str.data(), static_cast<unsigned>(str.size()), |
| 405 | &wstr[0], static_cast<unsigned>(wstr.size()) + 1)); |
| 406 | for (const auto ch : wstr) { |
| 407 | if (ch == 0xfffd) { |
| 408 | throw NonValidUTF8Exception(); |
| 409 | } |
| 410 | } |
| 411 | return wstr; |
| 412 | } |
| 413 | |
| 414 | // --------------------------------------------------------------------------- |
| 415 |
no test coverage detected