| 40 | namespace { |
| 41 | |
| 42 | std::wstring utf8_to_wide(const std::string& text) { |
| 43 | if (text.empty()) { |
| 44 | return {}; |
| 45 | } |
| 46 | |
| 47 | const auto size = MultiByteToWideChar(CP_UTF8, |
| 48 | MB_ERR_INVALID_CHARS, |
| 49 | text.data(), |
| 50 | static_cast<int>(text.size()), |
| 51 | nullptr, |
| 52 | 0); |
| 53 | if (size <= 0) { |
| 54 | return {}; |
| 55 | } |
| 56 | |
| 57 | std::wstring wide(static_cast<size_t>(size), L'\0'); |
| 58 | MultiByteToWideChar(CP_UTF8, |
| 59 | MB_ERR_INVALID_CHARS, |
| 60 | text.data(), |
| 61 | static_cast<int>(text.size()), |
| 62 | wide.data(), |
| 63 | size); |
| 64 | return wide; |
| 65 | } |
| 66 | |
| 67 | std::wstring quote_windows_arg(const std::wstring& arg) { |
| 68 | if (arg.empty()) { |
no test coverage detected