Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix converting the charset of an empty string. Thanks to MrData on th…
…e forums for reporting this issue.
  • Loading branch information
delroth committed Mar 17, 2013
1 parent f480697 commit 612c2e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Common/Src/StringUtil.cpp
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 612c2e8

Please sign in to comment.