Fix UTF8ToUTF16.

This commit is contained in:
Victor Zverovich 2014-05-01 07:20:38 -07:00
parent 73d98d5d17
commit 9830c52816

View File

@ -176,12 +176,12 @@ fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) {
CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, 0, 0);
static const char ERROR[] = "cannot convert string from UTF-8 to UTF-16";
if (length == 0)
ThrowSystemError(GetLastError(), ERROR);
ThrowWinError(GetLastError(), ERROR);
buffer_.resize(length);
length = MultiByteToWideChar(
CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, &buffer_[0], length);
if (length == 0)
ThrowSystemError(GetLastError(), ERROR);
ThrowWinError(GetLastError(), ERROR);
}
fmt::internal::UTF16ToUTF8::UTF16ToUTF8(fmt::WStringRef s) {