C0 and C1 control codes
From Wikipedia, the free encyclopedia
The C0 and C1 control code sets define control codes for use in text. C0, originally defined in ISO 646, defines codes in the range 00HEX–1FHEX. C1, originally defined in ISO 6429, defines codes in the range 80HEX–9FHEX. The C0 codes are contained in ASCII and most encodings based on it. The C1 codes are used in conjunction with the ISO/IEC 8859 series of graphical character sets among others, and are integrated into Unicode, but rarely used directly, except on specific platforms such as OpenVMS. When they turn up in documents, Web pages, e-mail messages, etc., which are ostensibly in an ISO-8859-n encoding, their code positions generally actually refer to the characters at that position in a proprietary, system-specific encoding such as Windows-1252 or the Apple Macintosh ("MacRoman") character set, though this is technically invalid under the ISO encodings. Such characters are more commonly accessed using the equivalent two octet escape sequence.
Most applications only interpret the C0 control codes for LF, CR, and HT. A few applications also interpret C0 codes VT and FF, and the C1 code NEL. Very few applications interpret the other C0 and C1 control codes. See ANSI escape codes for details about CSI (Control Sequence Introducer, C1 control code 9BHEX).
Contents |
[edit] C0 (ASCII and derivatives)
These are the standard ASCII control codes. If using the ISO/IEC 2022 extension mechanism, they are designated as the active C0 control character set with the octet sequence 0x1B 0x21 0x40 (ESC ! @).
| Seq | Dec | Hex | Acro | Name | C | Description | |||
|---|---|---|---|---|---|---|---|---|---|
^@ |
00 | 00 | NUL | Null | \0 |
Originally used to allow gaps to be left on paper tape for edits. Later used for padding after a code that might take a terminal some time to process (e.g. a carriage return or line feed on a printing terminal). Now often used as a string terminator, especially in the C programming language. | |||
^A |
01 | 01 | SOH | Start of Heading | First character of a message heading. In some computer terminals, moves cursor to the first column. | ||||
^B |
02 | 02 | STX | Start of Text | First character of message text, and may be used to terminate the message heading. | ||||
^C |
03 | 03 | ETX | End of Text | Often used as a "break" character (Ctrl-C) to interrupt or terminate a program or process. In TOPS-20, it was used to gain the system's attention before logging in. | ||||
^D |
04 | 04 | EOT | End of Transmission | Used on Unix to signal end-of-file condition on, or to logout from, a terminal. On Apple II systems, it signaled that a DOS command followed. | ||||
^E |
05 | 05 | ENQ | Enquiry | Signal intended to trigger a response at the receiving end, to see if it is still present. In some computer terminals and EMACS , moves the cursor to the end of current line. | ||||
^F |
06 | 06 | ACK | Acknowledge | Response to an ENQ, or an indication of successful receipt of a message. | ||||
^G |
07 | 07 | BEL | Bell | \a |
Originally used to sound a bell on the terminal. Later used for a beep on systems that didn't have a physical bell. May also quickly turn on and off inverse video (a visual bell). | |||
^H |
08 | 08 | BS | Backspace | \b |
Move the cursor one position leftwards. On input, this may delete the character to the left of the cursor. | |||
^I |
09 | 09 | HT | Horizontal Tab | \t |
Position to the next horizontal tab stop. | |||
^J |
10 | 0A | LF | Line Feed | \n |
On typewriters, printers, and some terminal emulators, moves the cursor down one row without affecting its column position. On Unix, used to mark end-of-line. In MS-DOS, Windows, and various network standards, used following CR as part of the end-of-line mark. | |||
^K |
11 | 0B | VT | Vertical Tab | \v |
Position the form at the next vertical tab stop. | |||
^L |
12 | 0C | FF | Form Feed | \f |
On printers, load the next page. Treated as whitespace in many programming languages, and may be used to separate logical divisions in code. In some terminal emulators, it clears the screen. | |||
^M |
13 | 0D | CR | Carriage Return | \r |
Originally used to move the cursor to column zero while staying on the same line. On Mac OS (pre-Mac OS X), as well as in earlier systems such as the Apple II and Commodore 64, used to mark end-of-line. In MS-DOS, Windows, and various network standards, it is used preceding LF as part of the end-of-line mark. The Enter or Return key on a keyboard will send this character, but it may be converted to a different end-of-line sequence by a terminal program. | |||
^N |
14 | 0E | SO | Shift Out | Switch to an alternate character set. | ||||
^O |
15 | 0F | SI | Shift In | Return to regular character set after Shift Out. In TOPS-20, it signalled that further output should be discarded; the program would continue to run but not display or print anything until ^O is typed again. | ||||
^P |
16 | 10 | DLE | Data Link Escape | Cause the following data to be interpreted as raw data, not control codes. | ||||
^Q |
17 | 11 | DC1 | Device Control 1, XON | Resume transmission. Used for software flow control. In some terminal programs, ends pause started with Ctrl-S. | ||||
^R |
18 | 12 | DC2 | Device Control 2 | In TOPS-20, reprinted the current line, tidying up any character deletions. | ||||
^S |
19 | 13 | DC3 | Device Control 3, XOFF | Suspend transmission. Used for software flow control. In some terminal programs, pauses display of text. | ||||
^T |
20 | 14 | DC4 | Device Control 4 | In TOPS-20, it caused a brief system-status line to be displayed. | ||||
^U |
21 | 15 | NAK | Negative Acknowledge | Sent by a station as a negative response to the station with which the connection has been set up. In binary synchronous communication protocol, the NAK is used to indicate that an error was detected in the previously received block and that the receiver is ready to accept retransmission of that block. In multipoint systems, the NAK is used as the not-ready reply to a poll. In some text editors, it was used as a "Delete Line" character. | ||||
^V |
22 | 16 | SYN | Synchronous Idle | Used in synchronous transmission systems to provide a signal from which synchronous correction may be achieved between data terminal equipment, particularly when no other character is being transmitted. In some terminal programs, allows literal entry of control codes without them being interpreted. | ||||
^W |
23 | 17 | ETB | End of Transmission Block | Indicates the end of a transmission block of data when data are divided into such blocks for transmission purposes. In some text editors, it is used as a "Delete Word" character which rubs out the previous text entry back to the preceding space. | ||||
^X |
24 | 18 | CAN | Cancel | Indicates that the data with which it is associated are in error or are to be disregarded, or cannot be represented on a particular device. | ||||
^Y |
25 | 19 | EM | End of Medium | |||||
^Z |
26 | 1A | SUB | Substitute | Originally intended for use as a transmission control character to indicate that garbled or invalid character had been received. It has often been put to use for other purposes when the in-band signaling of errors it provides is unneeded, especially where robust methods of error detection and correction are used, or where errors are expected to be rare enough to make using the character for other purposes advisable. | ||||
^[ |
27 | 1B | ESC | Escape | \e |
The ESC key on the keyboard will cause this character to be sent on most systems. It can be used in software user interfaces to exit from a screen, menu, or mode, or in device-control protocols (e.g., printers and terminals) to signal that what follows is a special command sequence rather than normal text. | |||
^\ |
28 | 1C | FS | File Separator | Can be used as delimiters to mark fields of data structures. If used for hierarchical levels, US is the lowest level (dividing plain-text data items), while RS, GS, and FS are of increasing level to divide groups made up of items of the level beneath it. The space character which follows in numerical order can be considered a lowest-level "word separator". | ||||
^] |
29 | 1D | GS | Group Separator | |||||
^^ |
30 | 1E | RS | Record Separator | |||||
^_ |
31 | 1F | US | Unit Separator | |||||
^? |
127 | 7F | DEL | Rubout/Delete | Not technically part of the C0 control character range, this was originally used to mark deleted characters on paper tape, since any character could be changed to all ones by punching holes everywhere. On VT100 compatible terminals, this is the character generated by the key labelled ⌫, usually called backspace on modern machines, and does not correspond to the PC delete key. | ||||
[edit] C1 (ISO 8859 and Unicode)
These are most common extended control codes. If using the ISO/IEC 2022 extension mechanism, they are designated as the active C0 control character set with the sequence 0x1B 0x22 0x43 (ESC " C). Individual control functions can be accessed with the 7-bit equivalents 0x1B 0x40 through 0x1B 0x4F (ESC @ through ESC _).
| Dec | Hex | Esc (0x1B+) | Short Acro[1] | Long Acro | Name | Description |
|---|---|---|---|---|---|---|
| 128 | 80 | 40 | PA | PAD | Padding Character | Listed as XXX in Unicode. Not part of ISO/IEC 6429. |
| 129 | 81 | 41 | HO | HOP | High Octet Preset | |
| 130 | 82 | 42 | BH | BPH | Break Permitted Here | Roughly equivalent to a soft hyphen except that the means for indicating is not necessarily a hyphen. |
| 131 | 83 | 43 | NH | NBH | No Break Here | Follows the graphic character that is not to be broken. |
| 132 | 84 | 44 | IN | IND | Index | Move the active position one line down, to eliminate ambiguity about the meaning of LF. Deprecated in 1986 and withdrawn in 1991 from ISO/IEC 6429 (ECMA-48). |
| 133 | 85 | 45 | NL | NEL | Next Line | Equivalent to CR+LF. Used to mark end-of-line on some IBM mainframes. |
| 134 | 86 | 46 | SA | SSA | Start of Selected Area | Used by block-oriented terminals. |
| 135 | 87 | 47 | ES | ESA | End of Selected Area | |
| 136 | 88 | 48 | HS | HTS | Character Tab Set Horizontal Tab Set |
|
| 137 | 89 | 49 | HJ | HTJ | Character Tab Justified Horizontal Tab Justified |
Similar to Character Tab, except that instead of space being placed after the preceding characters until the next character tab stop is reached, the space is placed before them. |
| 138 | 8A | 4A | VS | VTS | Line Tab Set Vertical Tab Set |
|
| 139 | 8B | 4B | PD | PLD | Partial Line Forward Partial Line Down |
Used to produce subscripts and superscripts in ISO/IEC 6429, e.g., in a printer. Subscripts use PLD text PLU while superscripts use PLU text PLD.. |
| 140 | 8C | 4C | PU | PLU | Partial Line Backward Partial Line Up |
|
| 141 | 8D | 4D | RI | RI | Reverse Line Feed Reverse Index |
|
| 142 | 8E | 4E | S2 | SS2 | Single-Shift 2 | Next character invokes a graphic from the G2 set. |
| 143 | 8F | 4F | S3 | SS3 | Single-Shift 3 | Next character invokes a graphic from the G3 set. |
| 144 | 90 | 50 | DC | DCS | Device Control String | Followed by a string of printable characters (0x20 through 0x7E) and format effectors (0x08 through 0x0D), terminated by ST (0x9C). |
| 145 | 91 | 51 | P1 | PU1 | Private Use 1 | Reserved for private use. |
| 146 | 92 | 52 | P2 | PU2 | Private Use 2 | |
| 147 | 93 | 53 | TS | STS | Set Transmit State | |
| 148 | 94 | 54 | CC | CCH | Cancel character | Destructive backspace, to eliminate ambiguity about meaning of BS. |
| 149 | 95 | 55 | MW | MW | Message Waiting | |
| 150 | 96 | 56 | SG | SPA | Start of Protected Area | Used by block-oriented terminals. |
| 151 | 97 | 57 | EG | EPA | End of Protected Area | |
| 152 | 98 | 58 | SS | SOS | Start of String | Followed by a control string terminated by ST (0x9C) that may contain any character except SOS or ST. |
| 153 | 99 | 59 | GC | SGCI | Single Graphic Character Introducer | Listed as XXX in Unicode. Not part of ISO/IEC 6429. |
| 154 | 9A | 5A | SC | SCI | Single Character Introducer | To be followed by a single printable character (0x20 through 0x7E) or format effector (0x08 through 0x0D). The intent was to provide a means by which a control function or a graphic character that would be available regardless of which graphic or control sets were in use could be defined. Definitions of what the following byte would invoke was never implemented in an international standard. |
| 155 | 9B | 5B | CI | CSI | Control Sequence Introducer | Used to introduce control sequences that take parameters. |
| 156 | 9C | 5C | SI | ST | String Terminator | |
| 157 | 9D | 5D | OC | OSC | Operating System Command | Followed by a string of printable characters (0x20 through 0x7E) and format effectors (0x08 through 0x0D), terminated by ST (0x9C). |
| 158 | 9E | 5E | PM | PM | Private Message | |
| 159 | 9F | 5F | AC | APC | Application Program Command |
[edit] References
- http://www.unicode.org/charts/PDF/U0000.pdf
- http://www.unicode.org/charts/PDF/U0080.pdf
- ATIS Telecom Glossary 2000
- De litteris regentibus C1 quaestiones septem or Are C1 characters legal in XHTML 1.0?
- W3C I18N FAQ: HTML, XHTML, XML and Control Codes
- International register of coded character sets to be used with escape sequences

