mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Replace std::to_string with locale-independent alternative
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user