使用的平台: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. web.xml配置之<context-param>详解

    读完本文,你将了解(1)<context-param>的作用和用法,(2)<context-param>配置和<init-param>的区别 <context ...

  2. PAT 天梯赛 L1-013. 计算阶乘和 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-013 AC代码 #include <iostream> #include <cstdio&g ...

  3. Maven实战--- dependencies与dependencyManagement的区别

    在上一个项目中遇到一些jar包冲突的问题,之后还有很多人分不清楚dependencies与dependencyManagement的区别,本篇文章将这些区别总结下来. 1.DepencyManagem ...

  4. 会话控制Session的应用

    Session技术与Cookie相似,都是用来存储使用者的相关资料.但是最大不同之处在于Cookie是将数据存放于客户端计算机中,而Session则是将数据存放于服务器系统下. 在Web技术发展史上, ...

  5. 20165101刘天野 2018-2019-2《网络对抗技术》Exp4 恶意代码分析

    20165101刘天野 2018-2019-2<网络对抗技术>Exp4 恶意代码分析 1. 实践目标 1.1是监控你自己系统的运行状态,看有没有可疑的程序在运行. 1.2是分析一个恶意软件 ...

  6. java/kotlin 读取文件、写入文件

    package dh.btb.backend.utils import java.io.*object FileUtil { /** * 创建文件 * @param filePath 文件路径(不要以 ...

  7. Spring 模块

  8. Curator的监听机制

    原生的zookeeper的监听API所实现的方法存在一些缺点,对于开发者来说后续的开发会考虑的细节比较多. Curator所实现的方法希望摒弃原声API 的不足,是开发看起来更加的简单,一些重连等操作 ...

  9. Spring Boot 设置启动时banner

    Spring Boot项目再启动的时候默认会在控制台输出一个字符banner图案,如下图: 我们可以通过下面的方法关闭启动时显示字符banner图案: 关闭banner方法一: public stat ...

  10. cf780c

                                                                                             C. Andryush ...