热门问题
时间线
聊天
视角
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