【boost】ptree 读写中文的问题

最经项目中使用到了boost property_tree,却在中文问题上遇到大问题。编码

直接使用ptree读写存储于窄字符(如string)类型的中文字符串时,程序能够运行,但因为XML默认使用UTF-8字符集,在xml文件中的中文字符不可读。spa

为了解决这个问题,有两个办法code

一、使用wptree和wstring方式配合,这种方式网上能够查到。xml

二、直接改变xml存储时的编码,如使用gb2312blog

        xml_writer_settings<char>  ss('*' ,0,"gb2312");
        write_xml(path, m_tree, std::locale(), ss);
相关文章
相关标签/搜索