Control character

来源:互联网 发布:mysql for mac 安装包 编辑:程序博客网 时间:2024/05/15 00:06

 

The control characters in ASCII still in common use include:

  • 0 (null, /0), originally intended to be an ignored character, but now used by many computer languages to terminate the end of a string.
  • 7 (bell, /a, ^G), which may cause the device receiving it to emit a warning of some kind (usually audible).
  • 8 (backspace, /b, ^H), used either to erase the last character printed or to overprint it.
  • 9 (horizontal tab, /t), moves the printing position some spaces to the right.
  • 10 (line feed, /n), used as the end_of_line marker in most UNIX systems and variants.
  • 12 (form feed, /f), to cause a printer to eject paper to the top of the next page, or a video terminal to clear the screen.
  • 13 (carriage return, /r, ^M), used as the end_of_line marker in Mac OS, OS-9, FLEX (and variants). A carriage return/line feed pair is used by CP/M-80 and its derivatives including DOS and Windows, and by application layer protocols such as HTTP.
  • 27 (escape, /e (gcc only)).
  • 127 (delete), originally intended to be an ignored character, but now used to erase a character (especially the one to the right of the cursor).

Occasionally one might encounter modern uses of other codes, such as code 4 (End of transmission), used to end a Unix shell session or PostScript printer transmission. For the full list of control characters, see ASCII.

Even though many control characters are rarely used, the concept of sending device-control information intermixed with printable characters is so useful that device makers found a way to send hundreds of device instructions. Specifically, they used ASCII code 27 (escape), followed by a series of characters called a "control sequence" or "escape sequence". The mechanism was invented by Bob Bemer, the father of ASCII.

Typically, code 27 was sent first in such a sequence to alert the device that the following characters were to be interpreted as a control sequence rather than as plain characters, then one or more characters would follow to specify some detailed action, after which the device would go back to interpreting characters normally. For example, the sequence of code 27, followed by the printable characters "[2;10H", would cause a DEC VT-102 terminal to move its cursor to the 10th cell of the 2nd line of the screen. Several standards exist for these sequences, notably ANSI X3.64. But the number of non-standard variations in use is large, especially among printers, where technology has advanced far faster than any standards body can possibly keep up with.

原创粉丝点击