std::fstream的中文目录问题

来源:互联网 发布:淘宝转化率1.39 编辑:程序博客网 时间:2024/06/04 18:04

std::fstream无法直接处理中文目录,解决方法之一如下


locale::global(locale(""))

file.open("d:\\中文路径.txt");

locale::global(locale("C")); //还原,否则cout有问题


不过如此一来, file<<n,当n大于1K时,会在数字中插入逗号(中文记数法),避免的方法是


locale::global(locale("",locale::all ^ locale::numeric))

file.open("d:\\中文路径.txt");

locale::global(locale("C")); //还原,否则cout有问题


0 0