以下解决方法转自百度知道:http://zhidao.baidu.com/question/335129108.html
using boost::property_tree::ptree;
ptree pt;
boost::array<string,400> tmpList;
read_xml(“E:\新建文件夹\test.xml”, pt);
会抛异常 can not open
如何才能让它支持中文路径
满意回答
2011-10-28 22:19
boost内部实际上用的是STL的串流
有时候用ifstream或ofstream打开带有中文路径的文件会失败。
解决办法:
1、使用C语言的函数设置为中文运行环境
setlocale(LC_ALL,"Chinese-simplified");
2、使用STL函数设置为系统语言环境
std::locale::global(std::locale(""));
当然选2啦!
boost::property_tree::wptree wpt;
std::locale::global(std::locale(""));
boost::property_tree::xml_parser::read_xml("E:\\新建文件夹\\test.xml",wpt);经试用,方法是成功的。
本文介绍了解决Boost库中read_xml函数无法处理中文路径的问题。通过设置系统的语言环境,使得函数能够正确读取含有中文字符的文件路径。
1771

被折叠的 条评论
为什么被折叠?



