From d056df033a1e88554f7cc39dd709a87b17cb49df Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Wed, 12 Feb 2020 23:01:45 -0500 Subject: Replace std::to_string with locale-independent alternative --- src/util/string.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/util') diff --git a/src/util/string.h b/src/util/string.h index 3db8fc8b98..694f0a1ca4 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -8,6 +8,8 @@ #include #include +#include +#include #include #include @@ -52,4 +54,16 @@ NODISCARD inline bool ValidAsCString(const std::string& str) noexcept return str.size() == strlen(str.c_str()); } +/** + * Locale-independent version of std::to_string + */ +template +std::string ToString(const T& t) +{ + std::ostringstream oss; + oss.imbue(std::locale::classic()); + oss << t; + return oss.str(); +} + #endif // BITCOIN_UTIL_STRENCODINGS_H -- cgit v1.2.3