用ofstream/ifstream 读写Unicod的TXT
使用的平台:vs2013 控制台
from: http://bbs.csdn.net/topics/360229403
xiayuanzhong:
ofstream ofs( "test.txt", ios::binary | ios::out );
ifstream ifs( "Test_Read.txt", ios::binary | ios::in );
wchar_t temp[ 2 ];
ifs.read( (char *)temp, 2 );
memset( temp, L'\0', sizeof(temp) );
ofs.write( "\xFF\xFE", 2 );
int k = 0;
while ( 1 ) {
k ++;
ifs.read( (char *)temp, 2 );
if ( ifs.eof( ) ) break;//经验表明,放在这里最恰当!~
ofs.write( (char *)temp, 2 );
}
ifs.close( );
ofs.close( );
unicode的TXT使用经验:
1.输出 换行符
ofstream ofs_c(FILE_NAME_C, ios::binary | ios::out);
ofs_c.write("\x0D\x00\x0A\x00", 4);// "\r\n"
2.输出空格
WCHAR_NULL8(ofs) (ofs).write("\x20\x00\x20\x00\x20\x00\x20\x00", 8);//" " x 4
用ofstream/ifstream 读写Unicod的TXT的更多相关文章
- C++读写文件ofstream,ifstream,fstream)[转]
在看C++编程思想中,每个练习基本都是使用ofstream,ifstream,fstream,以前粗略知道其用法和含义,在看了几位大牛的博文后,进行整理和总结: 这里主要是讨论fstream的内容:[ ...
- C++文件读写详解(ofstream,ifstream,fstream)
C++文件读写详解(ofstream,ifstream,fstream) 这里主要是讨论fstream的内容: #include <fstream> ofstream //文件写操作 内存 ...
- 【转载】C++文件读写详解(ofstream,ifstream,fstream)
原文:http://blog.csdn.net/kingstar158/article/details/6859379 在看C++编程思想中,每个练习基本都是使用ofstream,ifstream,f ...
- 【转】C++文件读写详解(ofstream,ifstream,fstream)
转:http://blog.csdn.net/kingstar158/article/details/6859379 摘要:具体用法,上面链接中,文章写的很详细,讲解ofstream,ifstream ...
- c++ ofstream & ifstream文件流操作
ofstream是从内存到硬盘,ifstream是从硬盘到内存,其实所谓的流缓冲就是内存空间; //ofstream & ifstream inherit from istream class ...
- C#读写记事本(txt)文件
C#写入记事本(txt)文件方法一: FileStream stream = new FileStream(@"d:\aa.txt",FileMode.Create);//file ...
- python读写不同编码txt文件
以后整理规范 import os import codecs filenames=os.listdir(os.getcwd()) out=file("name.txt",& ...
- clutter recoder
cin >> ch; cin.get(ch);区别读取输入是否忽略空格.制表等; char ch; ; cout << "Enter characters;enter ...
- 文件操作ofstream,open,close,ifstream,fin,依照行来读取数据, fstream,iosin iosout,fio.seekg(),文件写入和文件读写,文件拷贝和文件
1.ofstream,open,close 写入文件 #include<iostream> #include<fstream> using namespace std; ...
随机推荐
- springmvc pojo
/** * Spring MVC 会按请求参数名和 POJO 属性名进行自动匹配, 自动为该对象填充属性值.支持级联属性. * 如:dept.deptId.dept.address.tel 等 */ ...
- Eclipse 中安装Browse Deployment Location插件
Browse Deployment Location 功能的插件名称为: Pivotal tc Server Integration for Eclipse 可在Eclippse的Eclipse M ...
- CodeForces - 220B Little Elephant and Array (莫队+离散化 / 离线树状数组)
题意:N个数,M个查询,求[Li,Ri]区间内出现次数等于其数值大小的数的个数. 分析:用莫队处理离线问题是一种解决方案.但ai的范围可达到1e9,所以需要离散化预处理.每次区间向外扩的更新的过程中, ...
- C++类中成员变量的初始化总结
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- 查看linuxCPU信息
linux 下查看机器是cpu是几核的 几个cpu more /proc/cpuinfo |grep "physical id"|uniq|wc -l 每个cpu是几核(假设cpu ...
- LeetCode——Max Consecutive Ones
LeetCode--Max Consecutive Ones Question Given a binary array, find the maximum number of consecutive ...
- quartz(6)--集群
Quartz应用能被集群,是水平集群还是垂直集群取决于你自己的需要.集群提供以下好处: · 伸缩性 · 高可用性 · 负载均衡 目前,Quartz只能借助关系数据库和JDBC作业存储支持集群. qua ...
- MyEclipse中删除对Struts、Hibernate、Spring .
已经导入一下框架,现在发现不想用了,要删除,发现麻烦,添加容易删除不易,下面这个帮你解决删除问题,本文为转载,我试过hibenate,挺好使,你们验证其他的框架 http://blog.csdn.ne ...
- linux下gzip压缩同样内容大小不一样
一份数据,两种传输方式进行收集. 一份数据:有多台数据采集节点或者多个数据源 两种方式:一种是从依次多个采集节点或者多个数据源将数据拷贝过来,合并为一个文件 另外一种是多个采集节点或者数据源同时向汇总 ...
- bower 安装
安装Yeomannpm install --global yo搭建一个web应用脚手架,你将需要安装generator-webapp生成器:npm install -g generator-webap ...