摘记—Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Cha
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的更多相关文章
- 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 ...
- 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 ...
- 微软职位内部推荐-Principal Software Developer
微软近期Open的职位: Contact Person: Winnie Wei (wiwe@microsoft.com ) Work Location: Suzhou/Beijing News is ...
- 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 ...
- 今天看了《SOFT SKILLS The Software Developer's Life Manual》有感
从第四篇生产力开始看的,书中提到了专注,待续
- Linux环境下shell和vim中乱码原因及消除办法
shell和vim中乱码原因及消除办法 作者:Jack47 在Linux下开发,经常遇到乱码问题:shell或者vim中显示不了中文,或者能够显示,但不能输入中文.每次都是上网去搜,或者同事告诉我一些 ...
- [No000093]按住Alt 再按数字键敲出任意汉字和字符!
1.在notepad里,(中文系统下) 按住Alt 然后按52946最后放开Alt 按住Alt 然后按45230最后放开Alt 按住Alt 然后按50403最后放开Alt 你会看到"我爱你& ...
- UTF-8编码规则(转)
from:http://www.cnblogs.com/chenwenbiao/archive/2011/08/11/2134503.html UTF-8是Unicode的一种实现方式,也就是它的字节 ...
- 关于Unicode,字符集,字符编码,每个程序员都应该知道的事
关于Unicode,字符集,字符编码,每个程序员都应该知道的事 作者:Jack47 李笑来的文章如何判断一个人是否聪明?中提到: 必要.清晰.且准确的概念,是一切思考的基石.所谓思考,很大程度上,就是 ...
随机推荐
- (字符串)最长公共子序列(Longest-Common-Subsequence,LCS)
问题: 最长公共子序列就是寻找两个给定序列的子序列,该子序列在两个序列中以相同的顺序出现,但是不必要是连续的. 例如序列X=ABCBDAB,Y=BDCABA.序列BCA是X和Y的一个公共子序列,但是不 ...
- poj1837--Balance(dp:天平问题)
Balance Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 10773 Accepted: 6685 Descript ...
- Cass环境下光标无显示
先安装CAD2004,十字光标正常显示:再安装CASS7.0,光标就不显示了.现在不清楚是CAD的问题,还是CASS的问题,多半是后者.重新配置了CASS环境也不行. 于是,打开CAD选项,显示,窗口 ...
- C++生成十字绣图案(二) 面向对象
基本的十字绣线性生成中提供了判断下一步可以画的位置并且逐步生成的函数.以这些基本函数为基础,可以进行更多变化的图案设计. 为了方便的扩展,可以把线性生成写成一个类,以后的修改继承这个类. 头文件Bas ...
- ADS中编译现存项目时常见错误:无法打开文件\…\…\2440init.o的解决办法
错误提示如下: 解决方法: 重新编译即可.
- Swift2.1keyword @noescape介绍
@noescape优化编译器编译,swift 2.1引入. 函数假设有一个一个參数是closure的话,能够在前面加一个关键字@noescape表示在函数return前closure生命周期结束,能够 ...
- sonarqube 指定jdk
D:\sonarqube-6.3\conf\wrapper.conf wrapper.java.command=D:/other/jdk1.8.0_25/bin/java
- Openerp 7.0消息推送
在一个文档的state变化时,需要将变化情况告知关注用户,通过研究account.invoice的代码,发现是经过如下过程实现此功能的: 1.添加一个消息阶段: <record id=" ...
- C语言printf
1.调用格式为 printf("<格式化字符串>", <参量表>); 其中格式化字符串包括两部分内容: 一部分是正常字符, 这些字符将按原样输出; 另一部 ...
- 获取List对象的泛型类(原创)
群里一个伙计的需求,最后我提出了这种解决方案,不过他觉得多写俩括号增加了调用方的难度.还是先记下来吧,有时间看看还能不能再改造. 1.直接获取时获取不到的,类型被虚拟机擦除了2.利用子类实现父类的 ...