diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2018-03-10 13:16:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-03-10 13:16:00 +0100 |
| commit | d72947d638cd459c24b9f4c3fea0a763586cd96c (patch) | |
| tree | fb0783c69bbb8f7085b66d73aa42dfb43d1f7bb3 /Source/Core | |
| parent | a4ef133456a18178f345d3c25195bf74c0e83750 (diff) | |
| parent | 34be8488a5c59b8d70ea8ae048b0d5628d71ee0f (diff) | |
Merge pull request #6427 from JosJuice/thousandseparate-encoding
StringUtil: Fix Windows encoding in ThousandSeparate
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/StringUtil.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Source/Core/Common/StringUtil.h b/Source/Core/Common/StringUtil.h index b5632c364b..ec2e5c6337 100644 --- a/Source/Core/Common/StringUtil.h +++ b/Source/Core/Common/StringUtil.h @@ -45,15 +45,23 @@ std::string StripQuotes(const std::string& s); template <typename I> std::string ThousandSeparate(I value, int spaces = 0) { - std::ostringstream oss; +#ifdef _WIN32 + std::wostringstream stream; +#else + std::ostringstream stream; +#endif // std::locale("") seems to be broken on many platforms #if defined _WIN32 || (defined __linux__ && !defined __clang__) - oss.imbue(std::locale("")); + stream.imbue(std::locale("")); #endif - oss << std::setw(spaces) << value; + stream << std::setw(spaces) << value; - return oss.str(); +#ifdef _WIN32 + return UTF16ToUTF8(stream.str()); +#else + return stream.str(); +#endif } std::string StringFromBool(bool value); |
