void saveWideFileHead(std::ofstream& out)// 写入文件内容前,先写入BOM
{
char const* const utf16head = "\xFF\xFE";
out.write(utf16head, 2);
} void saveWideFileContent(std::ofstream& out, wchar_t const* str, int size)
{
char const* pos = (char const*)str;
out.write(pos, size);
} void saveWideFileCRLF(std::ofstream& out)// 写入回车换行符
{
char const* const utf16head = "\x0D\x00\x0A\x00";
out.write(utf16head, 4);
} void Test()
{
std::ofstream of("test.log", std::ios::binary | std::ios::out);
saveWideFileHead(of);
CString str("hello中国world1234");
saveWideFileContent(of, str, str.GetLength() * 2);
saveWideFileCRLF(of);
saveWideFileContent(of, str, str.GetLength() * 2);
of.close();
}

  

使用ofstream输出unicode的更多相关文章

  1. python print输出unicode字符

    命令行提示符下,python print输出unicode字符时出现以下 UnicodeEncodeError: 'gbk' codec can't encode character '\u30fb ...

  2. paip.utf-8,unicode编码的本质输出unicode文件原理 python

    paip.utf-8,unicode编码的本质输出unicode文件原理 python      #别的语言,java php都是unicode,走十python不一样.    #enddef  #t ...

  3. Dir /U /c 输出Unicode字符的特性

    比如某个目录列表如下: D:\Spec\a.txtD:\Spec\Dir・C.txtD:\Spec\else.txtD:\Spec\קתקווה.dataD:\Spec\中・文.txt 直接dir / ...

  4. pytest文档41-参数化 ids 用例描述为中文时控制台输出unicode编码问题(pytest_collection_modifyitems)

    前言 使用 pytest.mark.parametrize 参数化的时候,加 ids 参数用例描述有中文时,在控制台输出会显示unicode编码,中文不能正常显示. 使用 pytest_collect ...

  5. (55)Wangdao.com第八天_JavaScript 字符串中使用 \u 输出Unicode字符

    JavaScript中,使用Unicode 需要 \u 进行转义,格式 "\u十六进制" console.log(\u0031); console.log(\u0041); // ...

  6. C++输出中文字符(转)

    C++输出中文字符 1. cout 场景1: 在源文件中定义 const char* str = "中文" 在 VC++ 编译器上,由于Windows环境用 GBK编码,所以字符串 ...

  7. 从Java String实例来理解ANSI、Unicode、BMP、UTF等编码概念

    转(http://www.codeceo.com/article/java-string-ansi-unicode-bmp-utf.html#0-tsina-1-10971-397232819ff9a ...

  8. 【Windows编程】系列第四篇:使用Unicode编程

    上一篇我们学习了Windows编程的文本及字体输出,在以上几篇的实例中也出现了一些带有“TEXT”的Windows宏定义,有朋友留言想了解一些ANSI和Unicode编程方面的内容,本章就来了解和学习 ...

  9. Windows 程序支持 Unicode

    宽字符 阅读了 UTF-8 Everywhere 一文,推荐在程序中对于字符串都使用 UTF-8 编码.Unix-like 系统默认是支持 UTF-8 编码的Unicode字符串,标准库函数也默认支持 ...

随机推荐

  1. Asp.Net MVC Identity 2.2.1 使用技巧(三)

    使用用户管理器之用户注册 用户管理的基本功能模块中已经做好了,我们现在做一些调整. 1.修改用户名注册规则. 上一篇中可选操作已经详解了这里把基本的设置简介下. 打开App_Start/identit ...

  2. Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.

    System.Data.OracleClient 已经过时了.微软不再支持它. 因此,我建议你为. NET 使用Oracle数据提供程序:ODP.Net. 你可以从以下位置下载: 版本:Release ...

  3. ZT 第9章 Framework的启动过程

    所在位置: 图书 -> 在线试读 -> Android内核剖析 第9章 Framework的启动过程 9.3 zygote的启动 前面小节介绍了Framework的运行环境,以及Dalvi ...

  4. 021.5 IO流——字符流

    ###############基本功能写 FileWriter fw = new FileWriter("xxx.txt"); fw.write("哈喽"); ...

  5. angularJs的作用域和依赖注入

    一.angularJs的作用域 &scope这是局部作用域,先在局部作用域中找,如果没有就在全局作用域中找  &rootScope这是全局作用域 <!DOCTYPE HTML&g ...

  6. 使用tidylib解决不规则网页问题

    windows 下安装tidylib 先去https://pypi.python.org/pypi/pytidylib 下载pytidylib 跑官方提供的测试用例报错 ition 0: unexpe ...

  7. 3171. [TJOI2013]循环格【费用流】

    Description 一个循环格就是一个矩阵,其中所有元素为箭头,指向相邻四个格子.每个元素有一个坐标(行,列),其中左上角元素坐标为(0,0).给定一个起始位置(r,c) ,你可以沿着箭头防线在格 ...

  8. 【JavaScript】particle

    这是js实现的粒子动画,有两种模式,分别是zoom和line,它们对应的效果不同,但是原理都相同,具体分析如下: 部分程序如下: var p = this; p.originParams = orig ...

  9. Kali-linux密码在线破解

    为了使用户能成功登录到目标系统,所以需要获取一个正确的密码.在Kali中,在线破解密码的工具很多,其中最常用的两款分别是Hydra和Medusa.本节将介绍使用Hydra和Medusa工具实现密码在线 ...

  10. C#关于递归等等

    递归的例子1 计算1到100相加的值 public partial class Default4 : System.Web.UI.Page{    protected void Page_Load(o ...