diff options
| author | 2015-08-02 18:43:33 -0300 | |
|---|---|---|
| committer | 2015-08-02 19:03:55 -0300 | |
| commit | 48393d452cbd891eba335b2468b3e4aa3d7b2a4e (patch) | |
| tree | 395b80a0db70b77e0a1cf7bfb3ac2b2b05329553 /src/common/string_util.cpp | |
| parent | Merge pull request #999 from LittleWhite-tb/qt-save-location (diff) | |
| download | yuzu-48393d452cbd891eba335b2468b3e4aa3d7b2a4e.tar.gz yuzu-48393d452cbd891eba335b2468b3e4aa3d7b2a4e.tar.xz yuzu-48393d452cbd891eba335b2468b3e4aa3d7b2a4e.zip | |
Common: Work around bug in MSVC2015 standard library
The char16_t/char32_t implementations aren't present in the library and
cause linker errors. This is a known issue that wasn't fixed in VS2015
RTM.
Diffstat (limited to 'src/common/string_util.cpp')
| -rw-r--r-- | src/common/string_util.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index b2f7f7b1d..6d6fc591f 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -296,14 +296,28 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st | |||
| 296 | 296 | ||
| 297 | std::string UTF16ToUTF8(const std::u16string& input) | 297 | std::string UTF16ToUTF8(const std::u16string& input) |
| 298 | { | 298 | { |
| 299 | #if _MSC_VER >= 1900 | ||
| 300 | // Workaround for missing char16_t/char32_t instantiations in MSVC2015 | ||
| 301 | std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert; | ||
| 302 | std::basic_string<__int16> tmp_buffer(input.cbegin(), input.cend()); | ||
| 303 | return convert.to_bytes(tmp_buffer); | ||
| 304 | #else | ||
| 299 | std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; | 305 | std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; |
| 300 | return convert.to_bytes(input); | 306 | return convert.to_bytes(input); |
| 307 | #endif | ||
| 301 | } | 308 | } |
| 302 | 309 | ||
| 303 | std::u16string UTF8ToUTF16(const std::string& input) | 310 | std::u16string UTF8ToUTF16(const std::string& input) |
| 304 | { | 311 | { |
| 312 | #if _MSC_VER >= 1900 | ||
| 313 | // Workaround for missing char16_t/char32_t instantiations in MSVC2015 | ||
| 314 | std::wstring_convert<std::codecvt_utf8_utf16<__int16>, __int16> convert; | ||
| 315 | auto tmp_buffer = convert.from_bytes(input); | ||
| 316 | return std::u16string(tmp_buffer.cbegin(), tmp_buffer.cend()); | ||
| 317 | #else | ||
| 305 | std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; | 318 | std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert; |
| 306 | return convert.from_bytes(input); | 319 | return convert.from_bytes(input); |
| 320 | #endif | ||
| 307 | } | 321 | } |
| 308 | 322 | ||
| 309 | static std::string UTF16ToUTF8(const std::wstring& input) | 323 | static std::string UTF16ToUTF8(const std::wstring& input) |