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. java正则表达式校验移动电话、固话、邮编的校验

    package com.tmall.epp.web.module.util; import java.util.regex.Pattern; /** * 移动电话.固话.邮编的校验 * @since  ...

  2. LVS跨网段DR模式并使用ldirectord实现RS高可用性

    DR模型的工作过程: Client向VIP发起请求,请求被路由器接收到,转发给不同网段的Director的VIP,Director再通过私有网络转给RS服务器,RS服务器处理请求并通过自身配置的VIP ...

  3. August 14th 2017 Week 33rd Monday

    Life is like a watch, you can return to the starting point, they are not yesterday! 人生就像钟表,可以回到起点,却已 ...

  4. JVM线程状态,park, wait, sleep, interrupt, yeild 对比

    ---恢复内容开始--- JVM线程状态 NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING, TERMINATED BLOCKED是等待获得对象锁 WAIT ...

  5. Jackson实现Object对象与Json字符串的互转

    在项目开发过程中,当客户端与服务器响应时,数据交互是必不可少的.然而通过Json实现数据交互成为我们开发中的一部分,进而Jackson为我们的Json转化提供了很好的机制.下面我将利用实例总结如何使用 ...

  6. Scala 经典的模式匹配和尾递归

    Scala 经典的模式匹配和尾递归 package io import java.io.{BufferedWriter, File, FileWriter} import java.text.Simp ...

  7. 【LGP5162】WD与积木

    题目 场面过度玄学,容易引起不适 我们发现我们要求的这个期望由分母和分子两部分构成 易发现 \[Ans=\frac{\sum_{i=1}^nS_2(n,i)\times i\times i!}{\su ...

  8. java从字符串中提取数字的简单实例

    随便给你一个含有数字的字符串,比如: String s="eert343dfg56756dtry66fggg89dfgf"; 那我们如何把其中的数字提取出来呢?大致有以下几种方法, ...

  9. Quick setup

    Quick setup — if you’ve done this kind of thing before We recommend every repository include a READM ...

  10. RAID基本知识

    RAID是英文Redundant Array of Independent Disks(独立磁盘冗余阵列),简称磁盘阵列.下面将各个级别的RAID介绍如下. 一.为什么使用Raid? 1.对磁盘高速存 ...