miloyip / nativejson-benchmark

C/C++ JSON parser/generator benchmark
MIT License
1.95k stars 262 forks source link

Add tests for number parsing with locales that use comma for decimal separator #112

Open danpla opened 5 years ago

danpla commented 5 years ago

Some JOSN libraries (like the current ccan/json) use locale-dependent C routines like strtod() and snprintf() for reading and writing numbers. In a program that sets a C locale with a comma as the decimal separator (like Russian ru_RU.UTF-8) this will lead to implicit truncation of numbers (strtod() will ignore . and everything after it) and writing broken JSONs (because the numbers in the file will have commas instead of periods).

It would be nice to know which libraries fail to read and write numbers with a locale that use a comma as the decimal separator. If a library doesn't pass this test, others don't actually matter, because the library is useless in practice.