热门问题
时间线
聊天
视角
C0与C1控制字符
来自维基百科,自由的百科全书
Remove ads
C0与C1控制字符是ISO/IEC 2022定义的控制字符集。
C0控制字符集的码位范围00HEX–1FHEX;C1控制字符集的码位范围 80HEX–9FHEX。 默认的C0控制字符集起源于ISO 646 (ASCII)的定义。默认的C1控制字符集起源于ECMA-48 (后为ISO 6429)的定义。
Unicode
Unicode字符集定义了65个码位以兼容ISO/IEC 2022。Unicode控制字符覆盖了U+0000—U+001F (C0 控制字符), U+007F (delete), and U+0080—U+009F (C1 controls)。 Unicode仅对U+001C—U+001F, U+0009—U+000D, 与 U+0085限定了语义。其它控制字符的语义对Unicode透明,留给了高层协议。
C0 (ASCII及其派生)
ASCII定义了32个控制字符,再加上一个Delete字符。
在当时(20世纪六七十年代)这么多控制字符都是需要的,因为多字节表示的控制序列要求终端机实现一个状态机,这在当时的电传或机械终端非常困难。但现在仅有少数控制字符还被使用(如空白符范畴的BS, TAB, LF, VT, FF, CR),其它一些字符无用,还有一些改变了用途(如NUL表示C语言字符串的终止)。
一些传输协议如ANPA-1312对控制字符SOH, STX, ETX 与 EOT做了扩展使用。其它著名的如BEL, ACK, NAK 与 SYN现在过时了。
现代终端有很多控制符可通过多字节的ANSI转义序列(开头为ESC 与 '[')表示。
ASCII控制字符的标准最初定义为ANSI X3.4。对于ISO/IEC 2022扩展机制,称为主动的C0控制字符集,采用八进制表示0x1B 0x21 0x40
(ESC ! @
).
Remove ads
C1控制字符集
当8比特ISO/IEC 8859 ASCII扩展提出后,人们认识到把最高比特去掉后可打印字符不应该变成控制字符(显然Delete字符被认为是无害的)。因此,新的标准保留了对应于C0控制字符集的32个码位但最高比特置1,作为C1控制字符集。所有C1控制字符在标准中指定了用ESC开头的7比特字符序列表示,以向后兼容7比特传输。
除了几乎不用的NEL,C1控制符在UTF-8中需要2字节编码。
当这些码位用于现代文档、网页、电子邮件消息等表示时,虽然表面上是用包含C1控制字符集的ISO-8859-n编码,但通常这些码位被私有、系统相关的编码方案如Windows-1252或苹果公司的Macintosh (Mac OS Roman)字符集,把C1控制符的码位用作提供额外的可打印字符。
Remove ads
参见
- Control Pictures
- ANSI转义序列
注释
- The name BELL is assigned by Unicode to the unrelated emoji character 🔔 (U+1F514). While C0 and C1 control characters were not formally named by the Unicode standard itself at the time, this collided with existing use of BELL as the name of this control character in software following the previous versions of UTS#18 (the Unicode Regular Expressions standard),[1] e.g. in Perl.[2] Unicode now accepts ALERT and BEL (but not BELL) as formal aliases for the control character,[3] although the code chart still lists BELL as the ISO 6429 alias,[4] and the corresponding control picture code point is called SYMBOL FOR BELL. Perl subsequently switched to using BELL for the emoji in version 5.18.[5]
- The '\e' escape sequence is not part of ISO C and many other language specifications. However, it is understood by several compilers, including GCC.
Remove ads
参考文献
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads