jsoncpp 遇到繁体字内码的问题
(2011-11-23 00:37:10)
使用了jsoncpp一段时间,遇到的最大问题就是当遇到繁体字时,由于内码的问题导致解析出错。
例如"黒"内码最后是'\'的转义符号。唯有是修改代码做出特定的处理。不知道有没有其他更好的处理办法?
此问题不是因为中文的问题,是因为
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
* \param document UTF-8 encoded string containing the document to read.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them back during
* serialization, \c false to discard comments.
* This parameter is ignored if Features::allowComments_
* is \c false.
* \return \c true if the document was successfully parsed, \c false if an error occurred.
*/
* \param document UTF-8 encoded string containing the document to read.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them back during
* serialization, \c false to discard comments.
* This parameter is ignored if Features::allowComments_
* is \c false.
* \return \c true if the document was successfully parsed, \c false if an error occurred.
*/
Reader::( const std::string &document,
Value &root,
bool collectComments = true );
Value &root,
bool collectComments = true );
请注意输入的必须是utf-8编码的 string不能是本地编码的多字节,所以在输入字符串时不能使用本地编码,否则解析就会出错