平时嫌麻烦, 一般采用setlocale(LC_ALL,"Chinese-simplified"); 的方法, 基本也能解决问题, 虽然很多人说这个方法不好 , 懒的管了.
可当把程序设置为" 在静态库中使用MFC"时, 这个方法就不灵了, 如该链接中:http://blog.csdn.net/pizi0475/archive/2010/03/01/5335677.aspx, 提到的方法都不能解决问题.
网上查了多种方法, 测试发现这种方法是有效的:
WCHAR * MtoW(const char* str)
{
WCHAR* strA;
int i= MultiByteToWideChar(CP_ACP,0 ,(char*)str,-1,NULL,0);
strA = new WCHAR[i];
MultiByteToWideChar(CP_ACP,0,(char*)str,-1,strA,i);
return strA;
}
在OgreFileSystem.cpp的
DataStreamPtr FileSystemArchive::open(const String& filename) const 函数中:
origStream->open(MtoW(full_path.c_str()), std::ios::in | std::ios::binary); //使用MtoW转换一下
Everything is all righit.
浙公网安备 33010602011771号