diff options
| author | Leo Lam <leolino.lam@gmail.com> | 2017-11-11 23:24:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-11 23:24:48 +0100 |
| commit | 9a2745a977db3a1c83f9b5bdd8113fe8a5d05202 (patch) | |
| tree | b31abdd6ecd21fdcd4644669314dbfc2871d6948 /Source/Core/Common/StringUtil.cpp | |
| parent | 1e24a5f309b69689e43e5876d26dd6ad2a0b0f67 (diff) | |
| parent | 2c10ba9be1bd42264b097ca771ee808d3022a736 (diff) | |
Merge pull request #6188 from JosJuice/stringutil-cleanup
StringUtil cleanup
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
| -rw-r--r-- | Source/Core/Common/StringUtil.cpp | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index c904f150da..de06d3c3aa 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -410,24 +410,6 @@ void StringPopBackIf(std::string* s, char c) #ifdef _WIN32 -std::string UTF16ToUTF8(const std::wstring& input) -{ - auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), - nullptr, 0, nullptr, nullptr); - - std::string output; - output.resize(size); - - if (size == 0 || - size != WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), - &output[0], static_cast<int>(output.size()), nullptr, nullptr)) - { - output.clear(); - } - - return output; -} - std::wstring CPToUTF16(u32 code_page, const std::string& input) { auto const size = @@ -470,6 +452,11 @@ std::wstring UTF8ToUTF16(const std::string& input) return CPToUTF16(CP_UTF8, input); } +std::string UTF16ToUTF8(const std::wstring& input) +{ + return UTF16ToCP(CP_UTF8, input); +} + std::string SHIFTJISToUTF8(const std::string& input) { return UTF16ToUTF8(CPToUTF16(CODEPAGE_SHIFT_JIS, input)); @@ -569,11 +556,7 @@ std::string UTF8ToSHIFTJIS(const std::string& input) std::string UTF16ToUTF8(const std::wstring& input) { - std::string result = CodeToUTF8("UTF-16LE", input); - - // TODO: why is this needed? - result.erase(std::remove(result.begin(), result.end(), 0x00), result.end()); - return result; + return CodeToUTF8("UTF-16LE", input); } #endif |
