Numbers are emitted wrongly under non-C locales.
Botje opened this issue · 2 comments
Botje commented
From a question on StackOverflow:
int main(){
std::locale::global(std::locale(""));
YAML::Emitter out;
out << 2112;
std::cout << "Emitter for 2112 = " << out.c_str() << '\n';
}
When run under LC_ALL=en_US.UTF-8
this produces 2,112
which parses as a string "2,112"
.
Under LC_ALL=nl_BE.UTF-8
this becomes 2.112
, which is interpreted by other parsers as a floating point number.
tibyo commented
In my case, the line std::locale::global(std::locale(""));
is not required to produce this behaviour. I am not setting the global locale anywhere in my project*, the only reference to locale I make is the use of std::format("{:L} ...
but still the integer 2024 is being rendered as "2,024" by yaml-cpp.
- Maybe it's possible that a global locale setting is made by a third party library used in my project