In ASCII
The control characters in ASCII still in common use include:
- 0 (null,
NUL
,\0
,^@
), originally intended to be an ignored character, but now used by many programming languages to mark the end of a string. - 7 (bell,
BEL
,\a
,^G
), which may cause the device receiving it to emit a warning of some kind (usually audible). - 8 (backspace,
BS
,\b
,^H
), used either to erase the last character printed or to overprint it. - 9 (horizontal tab,
HT
,\t
,^I
), moves the printing position some spaces to the right. - 10 (line feed,
LF
,\n
,^J
), used as the end of line marker in most UNIX systems and variants. - 12 (form feed,
FF
,\f
,^L
), 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,
CR
,\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,
ESC
,\e
,^[
). - 127 (delete,
DEL
,^?
), originally intended to be an ignored character, but now used in some systems to erase a character. Also used by some Plan9 console programs to send an interrupt note to the current process.
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.
Read more about this topic: Control Character