使用的平台: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的更多相关文章

  1. C++读写文件ofstream,ifstream,fstream)[转]

    在看C++编程思想中,每个练习基本都是使用ofstream,ifstream,fstream,以前粗略知道其用法和含义,在看了几位大牛的博文后,进行整理和总结: 这里主要是讨论fstream的内容:[ ...

  2. C++文件读写详解(ofstream,ifstream,fstream)

    C++文件读写详解(ofstream,ifstream,fstream) 这里主要是讨论fstream的内容: #include <fstream> ofstream //文件写操作 内存 ...

  3. 【转载】C++文件读写详解(ofstream,ifstream,fstream)

    原文:http://blog.csdn.net/kingstar158/article/details/6859379 在看C++编程思想中,每个练习基本都是使用ofstream,ifstream,f ...

  4. 【转】C++文件读写详解(ofstream,ifstream,fstream)

    转:http://blog.csdn.net/kingstar158/article/details/6859379 摘要:具体用法,上面链接中,文章写的很详细,讲解ofstream,ifstream ...

  5. c++ ofstream & ifstream文件流操作

    ofstream是从内存到硬盘,ifstream是从硬盘到内存,其实所谓的流缓冲就是内存空间; //ofstream & ifstream inherit from istream class ...

  6. C#读写记事本(txt)文件

    C#写入记事本(txt)文件方法一: FileStream stream = new FileStream(@"d:\aa.txt",FileMode.Create);//file ...

  7. python读写不同编码txt文件

        以后整理规范 import os import codecs filenames=os.listdir(os.getcwd()) out=file("name.txt",& ...

  8. clutter recoder

    cin >> ch; cin.get(ch);区别读取输入是否忽略空格.制表等; char ch; ; cout << "Enter characters;enter ...

  9. 文件操作ofstream,open,close,ifstream,fin,依照行来读取数据, fstream,iosin iosout,fio.seekg(),文件写入和文件读写,文件拷贝和文件

     1.ofstream,open,close 写入文件 #include<iostream> #include<fstream> using namespace std; ...

随机推荐

  1. cdojR - Japan

    地址:http://acm.uestc.edu.cn/#/contest/show/95 题目: R - Japan Time Limit: 3000/1000MS (Java/Others)     ...

  2. $python包管理工具pip的安装和使用

    pip是python的一个非常好用的包管理工具,可以用来很方便地安装和管理各种三方库,本文对其基本用法进行介绍. 安装pip Windows系统上安装 python 2.7.9及以上版本的window ...

  3. h5打开App的方法。

    在浏览器中: 法1: location.href = `${scheme}`;//location跳转App是几乎所以情况都支持的. 法2: var ifr = document.createElem ...

  4. Entity FrameWork 配置 之连接字符串隐藏或重用

    C/S项目中使用EF,默认回生成app.config文件夹,软件打包安装成功之后就回生成一个对应exe.config.里面会包含配置的一些信息. 这里介绍给大家一种隐藏连接字符串的方式. 代码如下: ...

  5. Sybase:获取本月最后一天的日期的实现方法

    Sybase:获取本月最后一天的日期的实现方法 Oracle中查询月底那天的日期的函数为:last_day(). 在ASE中没有对应的函数,在Oracle移植到Sybase的时候,需要手动编写函数来实 ...

  6. MapReduce:输入是两个文件,file1代表工厂表,包含工厂名列和地址编号列;file2代表地址表,包含地址名列和地址编号列。要求从输入数据中找出工厂名和地址名的对应关系,输出"工厂名----地址名"表

    文件如下: file1: Beijing Red Star Shenzhen Thunder Guangzhou Honda Beijing Rising Guangzhou Development ...

  7. 俄罗斯最新开源的牛掰数据库ClickHouse

    ClickHouse是俄罗斯最近刚刚开源的用于数据库管理系统能够实时生成分析数据报告,性能非常强悍! 使用SQL查询. 他拥有切割你的数据更多的新方法 ClickHouse的性能超过同类市场上目前用于 ...

  8. Python caffe.TEST Example(Demo)

    下面提供了caffe python的六个测试demo,大家可以根据自己的需求进行修改. Example 1 From project FaceDetection_CNN-master, under d ...

  9. TP多条件sql查询,分组排序

    $k=M('order a'); $bj=$k->join("left join __CHANGE__ b on b.tb_name='order'and a.order_id=b.t ...

  10. spark学习14(spark local模式运行spark程序的报错)

    报错1 java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. 解 ...