Closed
Description
Oh, It is nice to use StreamWriterBuilder
and I can set the precision of float values.
But, I found that all the Non-Ascii characters are quoted.
After dived into the source code, I found the static String valueToQuotedStringN(const char* value, unsigned length)
, and it scared me: it try to quote non-ascii characters to unicode code-point according to the UTF8 rules, ignoring the actual String Encoding.
I know in the document or somewhere, it says the jsoncpp only support UTF-8, but I think the brutally quote them are not proper methods. The original Api, like FastWriter
, just return the raw bytes, Why not follow it?
Or, we can follow the json lib of Python, like
import json
s = [u"中文有时常用GB18030编码",]; # unicode
json_dumps = json.dumps(s, ensure_ascii=False) # get unicode again
that is, let us get the raw bytes by providing a settting.