| 16 | } |
| 17 | |
| 18 | wstring bytesToWide(const vector<uchar> &bin, UINT cp) { |
| 19 | if (bin.empty()) |
| 20 | return L""; |
| 21 | const int len = |
| 22 | ::MultiByteToWideChar(cp, 0, reinterpret_cast<LPCCH>(bin.data()), static_cast<int>(bin.size()), nullptr, 0); |
| 23 | if (len <= 0) |
| 24 | return L""; |
| 25 | wstring out(len, L'\0'); |
| 26 | ::MultiByteToWideChar(cp, 0, reinterpret_cast<LPCCH>(bin.data()), static_cast<int>(bin.size()), &out[0], len); |
| 27 | return out; |
| 28 | } |
| 29 | |
| 30 | vector<uchar> wideToBytes(const wstring &text, UINT cp, bool nullTerminated) { |
| 31 | const int len = ::WideCharToMultiByte(cp, 0, text.c_str(), -1, nullptr, 0, nullptr, nullptr); |
no test coverage detected