You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Hi, I'm not living in an English speaking country and as such I naturally set std::locale("") to make cpp use familiar number representations instead (This changes the decimal from a dot to a comma). There seems to be a problem where jsoncpp uses a string stream to parse decimals, and the input stream correctly uses the default locale set before, but this now differs from the locale required by Json.
To Reproduce
Steps to reproduce the behavior:
std::locale::global(std::locale("de_DE.UTF-8"));
jsonReader.parse("[123.45]", root, false);
Expected behavior
Should parse the number with dot as decimal without any issue.
Desktop (please complete the following information):
OS: Linux
Meson N/A
Ninja N/A
Additional context
The solution is to imbue the streams with the local required by json like is.imbue(std::local("en_US.UTF-8")) for the reader:
Describe the bug
Hi, I'm not living in an English speaking country and as such I naturally set
std::locale("")
to make cpp use familiar number representations instead (This changes the decimal from a dot to a comma). There seems to be a problem where jsoncpp uses a string stream to parse decimals, and the input stream correctly uses the default locale set before, but this now differs from the locale required by Json.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should parse the number with dot as decimal without any issue.
Desktop (please complete the following information):
Additional context
The solution is to imbue the streams with the local required by json like
is.imbue(std::local("en_US.UTF-8"))
for the reader:jsoncpp/src/lib_json/json_reader.cpp
Line 590 in 89e2973
jsoncpp/src/lib_json/json_reader.cpp
Line 1624 in 89e2973
Don't currently know if the writer is affected with sprintf:
jsoncpp/src/lib_json/json_writer.cpp
Line 127 in 89e2973
Workaround is to temporarily set the locale to en_US manually
The text was updated successfully, but these errors were encountered: