Replace std::to_string with locale-independent alternative

This commit is contained in:
Ben Woosley
2020-02-12 23:01:45 -05:00
parent 58c72880ff
commit d056df033a
19 changed files with 71 additions and 58 deletions

View File

@@ -8,6 +8,8 @@
#include <attributes.h>
#include <cstring>
#include <locale>
#include <sstream>
#include <string>
#include <vector>
@@ -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 <typename T>
std::string ToString(const T& t)
{
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss << t;
return oss.str();
}
#endif // BITCOIN_UTIL_STRENCODINGS_H