2013年11月25日

【boost】ptree 读写中文的问题

摘要: 最经项目中使用到了boost property_tree,却在中文问题上遇到大问题。直接使用ptree读写存储于窄字符(如string)类型的中文字符串时,程序可以运行,但由于XML默认使用UTF-8字符集,在xml文件中的中文字符不可读。为了解决这个问题,有两个办法1、使用wptree和wstring方式配合,这种方式网上可以查到。2、直接改变xml存储时的编码,如使用gb2312 xml_writer_settings ss('*' ,0,"gb2312"); write_xml(path, m_tree, std::locale(), ss); 阅读全文

posted @ 2013-11-25 09:34 小水坝 阅读(859) 评论(0) 推荐(0) 编辑

导航