BasicExcel另存为中文文件名出错的解决
来源:互联网 发布:2017网络十大英语热词 编辑:程序博客网 时间:2024/06/07 13:29
wcstombs使用需要设置中文环境,具体修改代码如下:
bool Block::Create(const wchar_t* filename)// PURPOSE: Create a new block file and open it.// PURPOSE: If file is present, truncate it and then open it.// PROMISE: Return true if file is successfully created and opened, false if otherwise.{// Create new filesize_t filenameLength = 2*wcslen(filename)+1;char* name = new char[filenameLength];size_t converted = 0;wcstombs_s(&converted, name, filenameLength, filename, _TRUNCATE);//name[filenameLength] = 0;setlocale(LC_ALL,"");file_.open(name, ios_base::out | ios_base::trunc);setlocale(LC_ALL,"C");file_.close();file_.clear();// Open the filebool ret = this->Open(filename);delete[] name;return ret;}bool Block::Open(const wchar_t* filename, ios_base::openmode mode)// PURPOSE: Open an existing block file.// PROMISE: Return true if file is successfully opened, false if otherwise.{// Open existing file for reading or writing or bothsize_t filenameLength = wcslen(filename);filename_.resize(2*filenameLength+1, 0);setlocale(LC_ALL,"");wcstombs(&*(filename_.begin()), filename, 2*filenameLength+1);file_.open(&*(filename_.begin()), mode | ios_base::binary);setlocale(LC_ALL,"C");if (!file_.is_open()) return false;mode_ = mode;// Calculate filesizeif (mode & ios_base::in){file_.seekg(0, ios_base::end);fileSize_ = file_.tellg();}else if (mode & ios_base::out){file_.seekp(0, ios_base::end);fileSize_ = file_.tellp();}else{this->Close();return false;}// Calculate last index + 1indexEnd_ = fileSize_/blockSize_ + (fileSize_ % blockSize_ ? 1 : 0);return true;}
0 0
- BasicExcel另存为中文文件名出错的解决
- BasicExcel 中文路径问题
- 跨平台中文文件名乱码的解决
- 跨平台中文文件名乱码的解决
- 解决导出中文文件名乱码的方法
- 解决teleport 下载的中文文件名乱码
- 解决中文文件名显示乱码的问题
- 解决中文文件名乱码
- ssh2 中文写入数据库出错的解决
- MySQL命令行插入中文出错的解决
- BasicExcel
- basicexcel
- 解决FlashFXP5 不能下载中文文件名文件的问题(显示文件名中文正常下载文件名是乱码)
- javascript初始化office控件另存为窗口的文件名
- 关于Ant的中文文件名乱码问题的解决
- java文件下载的中文文件名乱码问题的解决
- Banshee中文文件名乱码解决
- 终于解决了中文文件名文件下载的问题
- 在一个应用中,如何针对不同的外部客户系统,使用不同的数字证书?
- SequenceInputStream合并流
- java学习笔记代码块和继承
- 关于Unity3d中的LayerMask使用 .
- how to check if license is downloaded fully
- BasicExcel另存为中文文件名出错的解决
- Android BluetoothProfile之AVRCP
- Openstack 中cinder backup三种backend的对比
- MongoDB 性能分析
- xcode openssl
- NSUserDefaults 存储自定义对象
- 用CSS来控制字符长度和显示长度
- Xcode基本操作
- Spring源码在Eclipse上部署的操作配置