fix: use C locale by default

This commit is contained in:
Simon Gene Gottlieb
2024-07-17 13:06:39 +02:00
committed by Jesse Beder
parent 1d8ca1f35e
commit b95aa146ec
6 changed files with 19 additions and 0 deletions

View File

@@ -141,6 +141,7 @@ inline Emitter& Emitter::WriteIntegralType(T value) {
PrepareNode(EmitterNodeType::Scalar);
std::stringstream stream;
stream.imbue(std::locale("C"));
PrepareIntegralStream(stream);
stream << value;
m_stream << stream.str();
@@ -158,6 +159,7 @@ inline Emitter& Emitter::WriteStreamable(T value) {
PrepareNode(EmitterNodeType::Scalar);
std::stringstream stream;
stream.imbue(std::locale("C"));
SetStreamablePrecision<T>(stream);
bool special = false;

View File

@@ -171,6 +171,7 @@ ConvertStreamTo(std::stringstream& stream, T& rhs) {
\
static Node encode(const type& rhs) { \
std::stringstream stream; \
stream.imbue(std::locale("C")); \
stream.precision(std::numeric_limits<type>::max_digits10); \
conversion::inner_encode(rhs, stream); \
return Node(stream.str()); \
@@ -182,6 +183,7 @@ ConvertStreamTo(std::stringstream& stream, T& rhs) {
} \
const std::string& input = node.Scalar(); \
std::stringstream stream(input); \
stream.imbue(std::locale("C")); \
stream.unsetf(std::ios::dec); \
if ((stream.peek() == '-') && std::is_unsigned<type>::value) { \
return false; \

View File

@@ -121,6 +121,7 @@ template<typename Key, bool Streamable>
struct streamable_to_string {
static std::string impl(const Key& key) {
std::stringstream ss;
ss.imbue(std::locale("C"));
ss << key;
return ss.str();
}