📜  控制字符

📅  最后修改于: 2021-07-05 07:31:52             🧑  作者: Mango

控制字符不表示可打印的字符尚未而是用来启动特定的动作字符。相反,控制字符用于执行任何操作,以在显示器上打印可打印字符。它们也被用作带内信令,以引起符号扩展到内容以外的影响。

另一方面,可打印字符用于在屏幕上显示字符,例如字母,符号,数字和字母数字字符。有不同类型的控制字符,包括打印控制字符,数据结构控制字符和传输控制字符。条形码和RFID扫描仪的前缀或后缀部分经常使用大量此类字符。

1870年的Baudot代码中提供了一种控制字符:NUL和DEL。 1901年,Murray代码包括回车符(CR)和换行符(LF),而Baudot代码的不同变体包括其他控制字符。贝尔字符(BEL)响起了信号执行人员的声音,同样是早期的电传打字控制字符。

控制字符分为三部分0:

  1. ASCII控制字符–
    ASCII控制字符包含代码0–31(十六进制00–1F)。此范围也称为C0集。在32和127(十六进制20和7F)处有两个额外的控件。 ASCII表号0–31指定用于控制命令某些外围设备(例如打印机)的控制字符。例如,12表示换页/新建页面函数。此命令指示打印机转到下一页的开头。

    控制字符的集合涵盖了许多应用程序。有“格式效应器”,用于规范纯内容的呈现。有用于传输协议的“传输控制”和用于启动,运行和停止辅助设备的“设备控制”。

    有“信息分隔符”控制不同的信息位。存在其他控件,用于创建警告,显示文件/文本/代码/脚本的结尾以及用于处理错误。

    ASCII控制字符具有多种用途,例如文本布局,通信和设备控制,而这仅仅是冰山一角。

  2. C1控制字符–
    C1涵盖128-159(十六进制80-9F)。 C1本质上用于显示器和打印机。该集合由ANSI转义序列和VT100标识。

    C1套在1970年代末推出。尽管实际上部分控件也代表了不同的用途,但它基本上是用于控制监视器和打印机小工具的。 C1集旨在与C0集一起使用。

    C1套包含“格式效果器”,可在打印时控制水平和垂直移位。有用于描述换行符或换行符的“演示控件”。有用于结构和表单填充的“区域定义”控件。

  3. ISO 8859独特字符–
    ISO 8859是8位字符集的集合。集合包括不同的拉丁语,西里尔字母,希腊语,阿拉伯语,希伯来语和泰语字符。 ISO 8859是由Windows字符集(“ ANSI代码页”)标识的,但是它们之间确实是唯一的。

    ISO 8859具有两个重要字符:非中断(NBSP)和软连字符(SHY)。尽管事实上它们在ISO 8859中并不是真正的控制字符,但它们中的两个具有类似控制字符的属性。

以下是一些基本的控制代码

Caret Notation Hex Code Abbreviation Name Description
^@ 00 NULL Null Used to perform media-fill and allow gaps. Also used for padding after any code and to mark end of string, notably in programming language C/C++.
^A 01 STX Start of Header Used as first character of head of data broadcast/message. It is usually used as field separator in Apache Hadoop.
^B 02 SOT Start of Text Heads text and used to mark end of heading.
^C 03 ETX End of Text

Marks end of text. In keyboard input, it is frequently used as Break character to interrupt process.

Notably seen in Unix based command lines, nano editor, etc. as (^C) to break command.

^D 04 EOT End of Transmission

Used to mark end of transmission of one or more texts(may involve header, broadcast text, and post-text).

It is also used to mark end-of-file(EOF) on terminal in UNIX based OS.

^E 05 ENQ Enquiry Requests for reply from remote terminal, response may include transmitter identification and/or transmitter status.
^F 06 ACK Acknowledge This character is sent by receiver as approving response to sender. (Response to ENQ)
^G 07 ACK Bell A control character to call for attention. It may control alarm or attention devices. Initially, it was used to play bell sound on terminal.
^H 08 BS BackSpace Shifts cursor one character position behind. While in input mode this might delete character to left of cursor. When in output mode, character once written could not be deleted(Primitively).
^I 09 HT Horizontal Tabulation Shifts cursor to next determined character position on the same line.
^J 0A LF Line Feed Shifts cursor to equivalent character position of next line. It is used to mark end-of-line(EOF) in UNIX. In DOS/Windows LF is used after CR(Carriage Return) to mark end-of-line.
^K 0B VT Vertical Tabulation Shifts cursor at next line.
^L 0C FF Form Feed

It commands printer to discard current page and to proceed to print at the next one.

More so, it also acts as whitespace in various programming languages,

^M 0D CR Carriage Return Primitively used to move cursor to very first column while staying on the same line/row. In DOS, /Windows, it is used before LF to mark end-of-line(EOF). Enter/Return key corresponds to this character.
^N 0E SO Shift Out Switches to substitute character set.
^O 0F SI Shift In Reverts to general character set after Shift Out.
^P 10 DLE Data Link Escape It is used particularly to deliver additional data transmission control functions. Only graphic characters and transmission control characters can be used in DLE sequences.
^Q 11 DC1 Device Control 1 (XON) A device control character, basically dedicated to turning on or starting essential device. It might also be used to restore any device to basic mode of operation.
^R 12 DC2 Device Control 2 A device control character which is basically dedicated to turning on or starting essential device. It might also be used to set any device to special mode of operation
^S 13 DC3 Device Control 3 (XOFF) A device control character which is basically dedicated to turning off or stopping an essential device. Also acts as secondary step stop(e.g: wait, pause, stand-by or halt)
^T 14 DC4 Device Control 4 A device control character, basically dedicated to turning off al device. It might also be used for any device control purpose not granted by other DCs.
^U 15 NAK Negative acknowledge A control character sent by receiver as negative acknowledgment/response to transmitter. NAK also indicates that an error was identified in last received block.
^V 16 SYN Synchronous Idle Used by synchronous transmission network to provide signal from which synchronous rectification may be achieved between data terminal equipment
^W 17 ETB End of Transmission Block marks end of transmission segment of data (where data is divided into such segments for transmission)
^X 18 CAN Cancel Indicates that data preceding it is in error. Hence, data is to be ignored.
^Y 19 EM End of Medium A control character that can be used to find physical end of medium or end of wanted portion of data.
^Z 1A SUB Substitute Used as an alternative for character that has been detected to be invalid or in error. On Unix, ^Z is keyboard signal to suspend process. In DOS/Windows, it is used to mark end of file, in cmd terminal, text files and many scripts.
^[ 1B ESC Escape Esc key corresponds to this control character on almost every operating system. Used in many interface to escape from screen, menu, or process.,
^\ 1C FS File Separator Used to separate data logically, its specific purpose has to be defined for each application. When used in hierarchical order, it delimits data item called file.
^] 1D GS Group Separator Used to separate data logically; its specific purpose has to be defined for each application. When used in hierarchical order, it delimits data item called group.
^^ 1E RS Record Separator Used to separate data logically; its specific purpose has to be defined for each application. When used in hierarchical order, it delimits data item called record.
^_ 1F US Unit Separator Used to separate data logically; its specific purpose has to be defined for each application. When used in hierarchical order, it delimits data item called unit.
20 SP Space Space is graphic character. Shifts cursor to move by one character position.
^? 7F DEL Delete The delete control character is last character in ASCII repertoire. It was designed to erase incorrect characters.