Fix converting the charset of an empty string. Thanks to MrData on the forums for reporting this issue.

This commit is contained in:
Pierre Bourdon 2013-03-17 14:37:00 +01:00
parent f480697b9b
commit 612c2e8516
1 changed files with 2 additions and 2 deletions

View File

@ -395,7 +395,7 @@ std::string UTF16ToUTF8(const std::wstring& input)
std::string output;
output.resize(size);
if (size != WideCharToMultiByte(CP_UTF8, 0, input.data(), input.size(), &output[0], output.size(), nullptr, nullptr))
if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), input.size(), &output[0], output.size(), nullptr, nullptr))
output.clear();
return output;
@ -408,7 +408,7 @@ std::wstring CPToUTF16(u32 code_page, const std::string& input)
std::wstring output;
output.resize(size);
if (size != MultiByteToWideChar(code_page, 0, input.data(), input.size(), &output[0], output.size()))
if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), input.size(), &output[0], output.size()))
output.clear();
return output;