Kalpana Kalpana (Editor)

C0 and C1 control codes

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

The C0 and C1 control code or control character sets define control codes for use in text by computer systems that use the ISO/IEC 2022 system of specifying control and graphic characters. Most character encodings, in addition to representing printable characters, also have characters such as these that represent additional information about the text, such as the position of a cursor, an instruction to start a new line, or a message that the text has been received.

Contents

The C0 set defines codes in the range 00HEX–1FHEX and the C1 set defines codes in the range 80HEX–9FHEX. The default C0 set was originally defined in ISO 646 (ASCII), while the default C1 set was originally defined in ECMA-48 (harmonized later with ISO 6429). While other C0 and C1 sets are available for specialized applications, they are rarely used.

Encoding interoperability

While the C1 control characters are used in conjunction with the ISO/IEC 8859 series of graphical character sets among others, they are 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 refer instead to the characters at that position in a proprietary, system-specific encoding such as Windows-1252 or the Apple Macintosh (Mac OS Roman) character set that use the codes provided for representation of the C1 set with a single 8-bit byte to instead provide additional graphic characters, though this is technically invalid under the ISO encodings.

Unicode sets aside 65 code points for compatibility with ISO/IEC 2022. The Unicode control characters cover U+0000—U+001F (C0 controls), U+007F (delete), and U+0080—U+009F (C1 controls). Unicode only specifies semantics for U+001C—U+001F, U+0009—U+000D, and U+0085. The rest of the control characters are transparent to Unicode and their meanings are left to higher-level protocols. The C1 characters in Unicode require 2 bytes to be encoded in UTF-8 (for instance CSI at U+009B is encoded as the bytes 0xC2, 0x9B in UTF-8). Thus the corresponding control functions are more commonly accessed using the equivalent two byte escape sequence intended for use with systems that have only 7-bit bytes.

Protocol interoperability and use

Computer applications dealing with plain text only need to concern themselves with the six format effectors (0x08 through 0x0D) in the default C0 set. Only HT, LF, and CR are universally well handled. Occasionally BS is used to overprint two characters, and VT and FF are sometimes handled. On the other hand, the C1 control character NEL intended as a single byte substitute for the common two-byte sequence CR LF is often accepted by plain text applications. Very few applications interpret the other C0 and C1 control codes, as they are not needed for plain text.

The ESC code is used extensively to introduce commands to control printing and display devices, for instance in the ANSI escape codes, and Printer Command Language (PCL), the printer language from Hewlett-Packard printers and compatibles.

NUL has the meaning of "end of string" in the programming language C and derivatives such as C++. This meaning is usually not intended in a text stream, but the result is that NUL often cannot be assigned any other meaning.

In addition, some transmission protocols such as ANPA-1312 do make extensive use of control characters SOH, STX, ETX and EOT. Other well known but now nearly obsolete ones are BEL, ACK, NAK and SYN.

The official English language names of some control codes were revised in the most recent edition of the standard for control codes in general (ISO 6429:1992 or ECMA-48:1991) to be neutral with respect to the graphic characters used with them, and to not assume that, as in the Latin script, lines are written on a page from top to bottom and that characters are written on a line from left to right. The abbreviations used were not changed, as the standard had already specified that those would remain unchanged when the standard is translated to other languages. Where the name has been changed, the original name from which the abbreviation was derived is also given in small type in the tables below.

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 ! @).

C1 set

These are the most common extended control codes. If using the ISO/IEC 2022 extension mechanism, they are designated as the active C1 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 0x5F (ESC @ through ESC _).

References

C0 and C1 control codes Wikipedia