aboutsummaryrefslogtreecommitdiff
path: root/src/util/string.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/string.h')
-rw-r--r--src/util/string.h14
1 files changed, 14 insertions, 0 deletions
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 <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