| 426 | #ifdef _WIN32 |
| 427 | |
| 428 | fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) { |
| 429 | int length = MultiByteToWideChar( |
| 430 | CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, 0, 0); |
| 431 | static const char ERROR[] = "cannot convert string from UTF-8 to UTF-16"; |
| 432 | if (length == 0) |
| 433 | FMT_THROW(WindowsError(GetLastError(), ERROR)); |
| 434 | buffer_.resize(length); |
| 435 | length = MultiByteToWideChar( |
| 436 | CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, &buffer_[0], length); |
| 437 | if (length == 0) |
| 438 | FMT_THROW(WindowsError(GetLastError(), ERROR)); |
| 439 | } |
| 440 | |
| 441 | fmt::internal::UTF16ToUTF8::UTF16ToUTF8(fmt::WStringRef s) { |
| 442 | if (int error_code = convert(s)) { |
nothing calls this directly
no test coverage detected