BenVim / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
1 stars 0 forks source link

Decimal separator follows the locale #84

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.write a simple programm in c++ using rapidjson that does :
a) create a Value of type double ("myDouble",3.5)
b) print Value using FastWriter or StyledWriter (or Value.toStyledString)
2.set locale to fr_FR.UTF-8 in a terminal (i guess all locales that use by 
default the "," character as decimal separator
3.execute program from the terminal

What is the expected output? What do you see instead?
I expect to see {"myDouble":3.5}
but I see {"myDouble":3,5}

What version of the product are you using? On what operating system?
OS: Fedora 18
rapidjson: 0.11

Please provide any additional information below.
remark: Maybe there is an option that i didn't see, if it's so, sorry

Maybe it's not a bug, i guess it can appear logical that the library uses the 
default decimal separator of the local... But when a server expects a specific 
format for double, whatever the local is, the problem can be a real issue, and 
the workaround of changing locale is not really a good idea :/ Just for 
information, jsoncpp behaves the same, boost doesn't.

Original issue reported on code.google.com by drkm...@gmail.com on 3 Jul 2013 at 9:35

GoogleCodeExporter commented 8 years ago
"print Value using FastWriter or StyledWriter (or Value.toStyledString)"
sorry, i mismatched libraries

Here is the code:
    rapidjson::Document doc;
    doc.SetObject();
    rapidjson::Value value2(3.5) ;
    doc.AddMember("myFloat", value2, doc.GetAllocator()) ;
    rapidjson::StringBuffer strbuf;
    rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
        doc.Accept(writer);
        LOG_DEBUG("output : " << strbuf.GetString()) ;

Original comment by drkm...@gmail.com on 3 Jul 2013 at 10:09

GoogleCodeExporter commented 8 years ago

Original comment by milo...@gmail.com on 30 Jun 2014 at 4:54

GoogleCodeExporter commented 8 years ago
https://github.com/miloyip/rapidjson/issues/72

Original comment by milo...@gmail.com on 13 Jul 2014 at 5:07