c++ - Rapidjson does not encode utf8 sequence at all -
i'm trying use rapidjson escape utf8 sequences \uxxxx format, it's not working.
stringbuffer s; writer<stringbuffer, document::encodingtype, ascii<> > writer(s); writer.startobject(); writer.string("chinese"); writer.string("中文测试"); writer.endobject(); cout << s.getstring() << endl; the document says escaped it's erased.
i tried use autoutf template, here's no document memory stream either
any ideas? tried jsoncpp well, library not support unicode well
thanks @milo yip, forget mention i'm using visual studio 2010
i tried on os x , works:
{"chinese":"\u4e2d\u6587\u6d4b\u8bd5"} i think problem that, compiler using not encode literal string "中文测试" utf-8. linux/osx treats source code utf-8 windows not default.
you can try use c++11 utf-8 literal u8"中文测试". or can read strings utf-8 encoded file testing.
the question updated. on visual studio 2010 , after, there undocumented feature:
#pragma execution_character_set("utf-8") such literal characters encoded in utf-8. c++11 compatible compilers, u8"xxx" literal should used.
anyway, claim "rapidjson not encode utf8 sequence @ all" incorrect.
Comments
Post a Comment