diff options
| author | 2016-04-04 21:55:08 -0400 | |
|---|---|---|
| committer | 2016-04-04 21:55:08 -0400 | |
| commit | b39340849631f565cf5c32bfdbab9fdc0bd4db9d (patch) | |
| tree | 8112be75d7f65ced275221040231a0ca1ae4f415 /src/common/string_util.cpp | |
| parent | Merge pull request #1640 from lioncash/cpp14 (diff) | |
| parent | remove debug code (diff) | |
| download | yuzu-b39340849631f565cf5c32bfdbab9fdc0bd4db9d.tar.gz yuzu-b39340849631f565cf5c32bfdbab9fdc0bd4db9d.tar.xz yuzu-b39340849631f565cf5c32bfdbab9fdc0bd4db9d.zip | |
Merge pull request #1620 from LFsWang/path
Fix filename&path encode problem on Windows
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) | |||
| 320 | #endif | 320 | #endif |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | static std::string UTF16ToUTF8(const std::wstring& input) | 323 | static std::wstring CPToUTF16(u32 code_page, const std::string& input) |
| 324 | { | 324 | { |
| 325 | auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr); | 325 | auto const size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0); |
| 326 | 326 | ||
| 327 | std::string output; | 327 | std::wstring output; |
| 328 | output.resize(size); | 328 | output.resize(size); |
| 329 | 329 | ||
| 330 | if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()), nullptr, nullptr)) | 330 | if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()))) |
| 331 | output.clear(); | 331 | output.clear(); |
| 332 | 332 | ||
| 333 | return output; | 333 | return output; |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | static std::wstring CPToUTF16(u32 code_page, const std::string& input) | 336 | std::string UTF16ToUTF8(const std::wstring& input) |
| 337 | { | 337 | { |
| 338 | auto const size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0); | 338 | auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr); |
| 339 | 339 | ||
| 340 | std::wstring output; | 340 | std::string output; |
| 341 | output.resize(size); | 341 | output.resize(size); |
| 342 | 342 | ||
| 343 | if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()))) | 343 | if (size == 0 || size != WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size()), nullptr, nullptr)) |
| 344 | output.clear(); | 344 | output.clear(); |
| 345 | 345 | ||
| 346 | return output; | 346 | return output; |