What a Unicode string ?

The binaries in RAM have the final word. NOT string literals in Text Editor(VS, Emacs), but the executable binary(in .str section) or binary data file(like cookie cache file in some sort of encoding) and loaded into variables / data structures like std::string.

string literal only tells the compiler to treat string literals as UTF-8 or UTF-16( L / _T() ), and thus come into .str section of a executable file image on disk .

code point : index to letters in code pages.

code pages :non-ASCII values (values greater than 127) represent international characters. These code pages are used natively in Windows Me, and are also available on Windows NT and later.

0-31 : ANSI unprintable

32 - 127:ANSI printable

128 + : OEM charsets -> (codified into ANSI)  : ANSI code pages ( IBM,M$)

在 Unicode 使用之前,通过DBCS来操纵编码 single/double byte 混合的char。Joel 称之为, messy system。 尤其突出的,是char分界的问题,比方,s++ and s--  和 Windows'
AnsiNext and AnsiPrev 。

Unicode 通过fixed的2个byte。非常好地划定界限。

可是有例如以下的特点

(1)通过debate解决的:UTF-16的 non-ANSI 的 字符集合。 而且,因此导致UTF-16事实上并不仅是65536种可能字符。

(2)在UTF-16中,128下面的每一个char都会被扩展到2bytes,与原本的ANSI不兼容:须要改动之前的代码。

Windows API 在 NT 之后採用了UTF-16,因此,非常多API加上了A或者W的后缀。

(The "A" version handles text based on Windows code pages, while the "W" version handles Unicode text. )

对于英语国家的人来讲。事实上ANSI已经够用了。

(3) 2个byte自然有先后的问题,于是,须要加入BOM头来识别是little/big endian。

UTF-16 因为浪费空间的问题,被“冷遇”了几年,直到做出改进,得到UTF-8。

UTF-8是一个“变长”的编码系统。ANSI部分(0-127)是1byte的编码,这样,能够seamlessly和ANSI对接,而且不须要改动古老的代码。

之后,有2~6bytes不等的编码。但共同点是:没有一个byte是0x0。这一点,对于 old string-processing code that wants to use a single 0 byte as the null-terminator 就不会盲目截断strings了。

摘记—Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Cha的更多相关文章

  1. The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Cha

    The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Cha ...

  2. Which SQL statement is the trump card to the senior software developer

    Which SQL statement is the trump card to the senior software developer                    MA Genfeng ...

  3. 微软职位内部推荐-Principal Software Developer

    微软近期Open的职位: Contact Person: Winnie Wei (wiwe@microsoft.com ) Work Location: Suzhou/Beijing News is ...

  4. 5 Tips for creating good code every day; or how to become a good software developer

    Being a good developer is like being any other good professional, it’s all it’s about doing as much ...

  5. 今天看了《SOFT SKILLS The Software Developer's Life Manual》有感

    从第四篇生产力开始看的,书中提到了专注,待续

  6. Linux环境下shell和vim中乱码原因及消除办法

    shell和vim中乱码原因及消除办法 作者:Jack47 在Linux下开发,经常遇到乱码问题:shell或者vim中显示不了中文,或者能够显示,但不能输入中文.每次都是上网去搜,或者同事告诉我一些 ...

  7. [No000093]按住Alt 再按数字键敲出任意汉字和字符!

    1.在notepad里,(中文系统下) 按住Alt 然后按52946最后放开Alt 按住Alt 然后按45230最后放开Alt 按住Alt 然后按50403最后放开Alt 你会看到"我爱你& ...

  8. UTF-8编码规则(转)

    from:http://www.cnblogs.com/chenwenbiao/archive/2011/08/11/2134503.html UTF-8是Unicode的一种实现方式,也就是它的字节 ...

  9. 关于Unicode,字符集,字符编码,每个程序员都应该知道的事

    关于Unicode,字符集,字符编码,每个程序员都应该知道的事 作者:Jack47 李笑来的文章如何判断一个人是否聪明?中提到: 必要.清晰.且准确的概念,是一切思考的基石.所谓思考,很大程度上,就是 ...

随机推荐

  1. 翻译记忆软件-塔多思TRADO经典教程_2

    Trados 中文简明教程Trados 中文简明教程1. 准备工作 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  2. ZH奶酪:在博客中添加Latex公式

    1. 点击编辑器中的插入图片: 2.在URL输入下边的地址: http://latex.codecogs.com/gif.latex?你的latex代码 就可以了-

  3. Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-6.xml, reason: Connection to https://dl-ssl.google.com refused

    修改hosts文件.文件在C:\WINDOWS\system32\drivers\etc目录下,Linux用户打开/etc/hosts文件.用记事本打开文件后添加以下内容. #Google主页203. ...

  4. Hibernate生成实体类-手工写法(一)

    BaseDao package com.pb.dao; import java.sql.Connection; import java.sql.DriverManager; import java.s ...

  5. Java从零开始学十(Arrays类对数组的常用方法)

    一.Arrays类常用方法 二.简单例子 package com.pb.demo1; import java.util.Arrays; /* * Arrays工具类的中的几个常用方法 * 1.copy ...

  6. PyQt5教程——对话框(6)

    PyQt5中的对话框 对话框窗口或对话框是大多数主流GUI应用不可缺少的部分.对话是两个或更多人之间的会话.在计算机应用中,对话框是一个用来和应用对话的窗口.对话框可以用来输入数据,修改数据,改变应用 ...

  7. Wireshark基本介绍和TCP三次握手

    转自:http://www.cnblogs.com/TankXiao/archive/2012/10/10/2711777.html 之前写过一篇博客:用 Fiddler 来调试HTTP,HTTPS. ...

  8. 图说十大数据挖掘算法(一)K最近邻算法

    如果你之前没有学习过K最近邻算法,那今天几张图,让你明白什么是K最近邻算法. 先来一张图,请分辨它是什么水果 很多同学不假思索,直接回答:“菠萝”!!! 仔细看看同学们,这是菠萝么?那再看下边这这张图 ...

  9. 剑指offer(2) - 二维数组中的查找

    题目: 在一个二维数组中.每一行都依照从左到右递增的顺序排序,每一列都依照从上往下递增的顺序排序.请写一个函数,输入一个二维数组和一个整数,推断数组中是否含有该整数. 比如以下的二维数组就是每行.每列 ...

  10. How to hide the create button dynamical tree view in openerp ?

    <tree create="false" edit="false" > <tree attrs="{'create':[(" ...