ogre无法读取中文路径的解决办法
来源:互联网 发布:淘宝用户名可以更改吗 编辑:程序博客网 时间:2024/06/09 22:59
下面是一段ogre中的文件操作相关的源码
代码
DataStreamPtr FileSystemArchive::open(const String& filename) const { String full_path = concatenate_path(mName, filename); // Use filesystem to determine size // (quicker than streaming to the end and back) struct stat tagStat; int ret = stat(full_path.c_str(), &tagStat); assert(ret == 0 && "Problem getting file size" ); // Always open in binary mode std::ifstream *origStream = OGRE_NEW_T(std::ifstream, MEMCATEGORY_GENERAL)(); origStream->open(full_path.c_str(), std::ios::in | std::ios::binary); // Should check ensure open succeeded, in case fail for some reason. if (origStream->fail()) { OGRE_DELETE_T(origStream, basic_ifstream, MEMCATEGORY_GENERAL); OGRE_EXCEPT(Exception::ERR_FILE_NOT_FOUND, "Cannot open file: " + filename, "FileSystemArchive::open"); } /// Construct return stream, tell it to delete on destroy FileStreamDataStream* stream = OGRE_NEW FileStreamDataStream(filename, origStream, tagStat.st_size, true); return DataStreamPtr(stream); }
主要的代码是
origStream->open(full_path.c_str(), std::ios::in | std::ios::binary);
通过在文件流打开文件之前,我们设置一下语言环境
std::locale::global(std::locale(""));
接下来我们发现,中文路径的问题解决了,但是向文件中写入整型或浮点型数据时会有问题,比如“1000”,输出之后就成了“1,000”
这正是因为我们改变了语言环境的原因,为了将修改减少到最小,我们应该在文件打开完毕后,恢复之前的设置
std::locale saveLocal = std::locale::global(std::locale(""));origStream->open(full_path.c_str(), std::ios::in | std::ios::binary);std::locale::global(saveLocal);
- ogre无法读取中文路径的解决办法
- ogre中文路径支持
- 解决Android无法读取中文路径问题及中文文件名
- Serv-U中文文件名或路径 无法上传与下载的解决办法
- 备忘-Linux下Code::blocks无法编译含有中文路径的解决办法
- 使用android stuido 编译项目时,项目的路径包含中文无法编译成功解决办法
- ArcEngine无法读取中文路径栅格数据集
- Python读取中文路径时的处理
- Python读取中文路径时的处理
- Python读取中文路径时的处理
- 路径名过长无法删除的解决办法
- spring无法读取方案文档的解决办法
- Poco库中文路径的解决办法
- Tomcat不支持中文路径的解决办法
- tomcat不支持中文路径(链接)的解决办法
- mysql控制台无法输入中文的解决办法
- s:TextArea无法输入中文的解决办法
- PowerPoint2007文本框无法输入中文的解决办法
- Linux线程-终止
- Oracle 版本查看及版本号说明
- 设计模式之外观模式
- Android系统框架详解
- 计算机网络----宽带速度kbps、KB、Mbps
- ogre无法读取中文路径的解决办法
- 将年月日时分秒都保存进数据库
- LaTex Templates and Samples for Writing IEEE Conference Paper
- android 相机获取照片显示代码实例
- mysql视图简介
- 测试面试
- nagios插件之计算内存使用率
- hibernate 解决插入时间默认不支持时分秒
- OGRE 源码编译问题 集合 [choose rendering subsystem ]