diff options
author | LFsWang <tnst92002@gmail.com> | 2016-03-31 12:58:37 +0200 |
---|---|---|
committer | LFsWang <tnst92002@gmail.com> | 2016-03-31 12:58:37 +0200 |
commit | acfa76aa381f7220606962777510809fa55a6a04 (patch) | |
tree | ac53fbf9d105f913c87ca1acf4ba2595bfe4e598 /src/common/string_util.cpp | |
parent | Merge pull request #1611 from ObsidianX/cfg-common-fix (diff) | |
download | yuzu-acfa76aa381f7220606962777510809fa55a6a04.tar yuzu-acfa76aa381f7220606962777510809fa55a6a04.tar.gz yuzu-acfa76aa381f7220606962777510809fa55a6a04.tar.bz2 yuzu-acfa76aa381f7220606962777510809fa55a6a04.tar.lz yuzu-acfa76aa381f7220606962777510809fa55a6a04.tar.xz yuzu-acfa76aa381f7220606962777510809fa55a6a04.tar.zst yuzu-acfa76aa381f7220606962777510809fa55a6a04.zip |
Diffstat (limited to 'src/common/string_util.cpp')
-rw-r--r-- | src/common/string_util.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 6d6fc591f..f0aa072db 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -320,27 +320,27 @@ std::u16string UTF8ToUTF16(const std::string& input) #endif } -static std::string UTF16ToUTF8(const std::wstring& input) +static std::wstring CPToUTF16(u32 code_page, const std::string& input) { - auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr); + auto const size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0); - std::string output; + std::wstring 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)) + if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()))) output.clear(); return output; } -static std::wstring CPToUTF16(u32 code_page, const std::string& input) +std::string UTF16ToUTF8(const std::wstring& input) { - auto const size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0); + auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr); - std::wstring output; + std::string output; output.resize(size); - if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.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; |