| 142 | } |
| 143 | |
| 144 | std::wstring AnsiStringToWideString(const char* str) |
| 145 | { |
| 146 | std::wstring ret; |
| 147 | const int length = MultiByteToWideChar( |
| 148 | CP_ACP, |
| 149 | MB_ERR_INVALID_CHARS, |
| 150 | str, |
| 151 | -1, |
| 152 | nullptr, |
| 153 | 0); |
| 154 | if (length <= 0) |
| 155 | throw std::runtime_error("MultiByteToWideChar failed"); |
| 156 | ret.resize(length); |
| 157 | MultiByteToWideChar( |
| 158 | CP_ACP, |
| 159 | MB_ERR_INVALID_CHARS, |
| 160 | str, |
| 161 | -1, |
| 162 | ret.data(), |
| 163 | length); |
| 164 | while (!ret.empty() && ret.back() == 0) |
| 165 | ret.pop_back(); |
| 166 | return ret; |
| 167 | } |
| 168 | |
| 169 | std::string WideToUtf8String(const std::wstring& wStr) |
| 170 | { |
no outgoing calls
no test coverage detected