Control character

Control character

In computing and telecommunication, a control character or non-printing character is a code point (a number) in a character set, that does not in itself represent a written symbol. It is in-band signaling in the context of character encoding. All entries in the ASCII table below code 32 (technically the C0 control code set) and 127 are of this kind, including BEL (which is intended to cause an audible signal in the receiving terminal), SYN (which is a synchronization signal), and ENQ (a signal that is intended to trigger a response at the receiving end, to see if it is still present). The Extended Binary Coded Decimal Interchange Code (EBCDIC) character set contains 65 control codes, including all of the ASCII control codes as well as additional codes which are mostly used to control IBM peripherals. Unicode makes a distinction between Control characters (C0 and C1 control codes) versus Formatting characters (such as the Zero-width non-joiner).

Other characters are printing, printable, or graphic characters, except perhaps for the "space" character (see ASCII printable characters).

[1] 0x00 0x10
0x00 NUL DLE
0x01 SOH DC1
0x02 STX DC2
0x03 ETX DC3
0x04 EOT DC4
0x05 ENQ NAK
0x06 ACK SYN
0x07 BEL ETB
0x08 BS CAN
0x09 TAB EM
0x0C FF FS
0x0D CR GS
0x0E SO RS
0x0F SI US
0x7F DEL



Procedural signs in Morse code are a form of control character.

A form of control characters were introduced in the 1870 Baudot code: NUL and DEL. The 1901 Murray code added the carriage return (CR) and line feed (LF), and other versions of the Baudot code included other control characters.

The bell character (BEL), which rang a bell to alert operators, was also an early teletype control character.

They have also been called "format effectors".


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 [GCC only], ^[).
  • 127 (delete, DEL, ^?), originally intended to be an ignored character, but now used in some systems to erase a character.

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.

In Unicode

In Unicode, "Control-characters" are those defined in C0 and C1 control codes. Their General Category is "Cc". Formatting codes are distinct, in General Category "Cf". The Cc control characters have no Name in Unicode. They may be indicated informally as "<control-001A>".[2]


There are a number of techniques to display non-printing characters, which may be illustrated with the bell character in ASCII encoding:

  • Code point: decimal 7, hexadecimal 0x07
  • An abbreviation, often three capital letters: BEL
  • A special character: Unicode U+2407 (␇), "symbol for bell" (note that this uses the abbreviation, specially formatted)
  • Caret notation in ASCII, where code point 00xxxxx is represented as a caret followed by the capital letter at code point 10xxxxx: ^G
  • An escape sequence, as in printf codes: \a

How control characters map to keyboards

ASCII-based keyboards have a key labelled "Control", "Ctrl", or (rarely) "Cntl" which is used much like a shift key, being pressed in combination with another letter or symbol key. In one implementation, the control key generates the code 64 places below the code for the (generally) uppercase letter it is pressed in combination with (i.e., subtract 64 from ASCII code value in decimal of the (generally) uppercase letter). The other implementation is to take the ASCII code produced by the key and bitwise AND it with 63, forcing bits 6 and 7 to zero. For example, pressing "control" and the letter "g" or "G" (code 103 or 71 in base 10, which is 01000111 in binary, produces the code 7 (Bell, 7 in base 10, or 00000111 in binary). The NULL character (code 0) is represented by Ctrl-@, "@" being the code immediately before "A" in the ASCII character set. For convenience, a lot of terminals accept Ctrl-Space as an alias for Ctrl-@. In either case, this produces one of the 32 ASCII control codes between 0 and 31. This approach is not able to represent the DEL character because of its value (code 127), but Ctrl-? is often used for this character, as subtracting 64 from a '?' gives −1, which if masked to 7 bits is 127.[3]

When the control key is held down, letter keys produce the same control characters regardless of the state of the shift or caps lock keys. In other words, it does not matter whether the key would have produced an upper-case or a lower-case letter. The interpretation of the control key with the space, graphics character, and digit keys (ASCII codes 32 to 63) vary between systems. Some will produce the same character code as if the control key was not held down. Other systems translate these keys into control characters when the control key is held down. The interpretation of the control key with non-ASCII ("foreign") keys also varies between systems.

Control characters are often rendered into a printable form known as caret notation by printing a caret (^) and then the ASCII character that has a value of the control character plus 64. Control characters generated using letter keys are thus displayed with the upper-case form of the letter. For example, ^G represents code 7, which is generated by pressing the G key when the control key is held down.

Keyboards also typically have a few single keys which produce control character codes. For example, the key labelled "Backspace" typically produces code 8, "Tab" code 9, "Enter" or "Return" code 13 (though some keyboards might produce code 10 for "Enter").

Many keyboards include keys that do not correspond to any ASCII printable or control character, for example cursor control arrows and word processing functions. The associated keypresses are communicated to computer programs by one of four methods: appropriating otherwise unused control characters; using some encoding other than ASCII; using multi-character control sequences; or using an additional mechanism outside of generating characters. "Dumb" computer terminals typically use control sequences. Keyboards attached to stand-alone personal computers made in the 1980s typically use one (or both) of the first two methods. Modern computer keyboards generate scancodes that identify the specific physical keys that are pressed; computer software then determines how to handle the keys that are pressed, including any of the four methods described above.

The design purpose

The control characters were designed to fall into a few groups: printing and display control, data structuring, transmission control, and miscellaneous.

Printing and display control

Printing control characters were first used to control the physical mechanism of printers, the earliest output device. An early implementation of this idea was the out-of-band ASA carriage control characters. Later, control characters were integrated into the stream of data to be printed. The carriage return character (CR), when sent to such a device, causes it to put the character at the edge of the paper at which writing begins (it may, or may not, also move the printing position to the next line). The line feed character (LF/NL) causes the device to put the printing position on the next line. It may (or may not), depending on the device and its configuration, also move the printing position to the start of the next line (whichever direction is first—left in Western languages and right in Hebrew and Arabic). The vertical and horizontal tab characters (VT and HT/TAB) cause the output device to move the printing position to the next tab stop in the direction of reading. The form feed character (FF/NP) starts a new sheet of paper, and may or may not move to the start of the first line. The backspace character (BS) moves the printing position one character space backwards. On printers, this is most often used so the printer can overprint characters to make other, not normally available, characters. On terminals and other electronic output devices, there are often software (or hardware) configuration choices which will allow a destruct backspace (i.e., a BS, SP, BS sequence) which erases, or a non-destructive one which does not. The shift in and shift out characters (SO and SI) selected alternate character sets, fonts, underlining or other printing modes. Escape sequences were often used to do the same thing.

With the advent of computer terminals that did not physically print on paper and so offered more flexibility regarding screen placement, erasure, and so forth, printing control codes were adapted. Form feeds, for example, usually cleared the screen, there being no new paper page to move to. More complex escape sequences were developed to take advantage of the flexibility of the new terminals, and indeed of newer printers. The concept of a control character had always been somewhat limiting, and was extremely so when used with new, much more flexible, hardware. Control sequences (sometimes implemented as escape sequences) could match the new flexibility and power and became the standard method. However, there were, and remain, a large variety of standard sequences to choose from.

Data structuring

The separators (File, Group, Record, and Unit: FS, GS, RS and US) were made to structure data, usually on a tape, in order to simulate punched cards. End of medium (EM) warns that the tape (or other recording medium) is ending. While many systems use CR/LF and TAB for structuring data, it is possible to encounter the separator control characters in data that needs to be structured. The separator control characters are not overloaded; there is no general use of them except to separate data into structured groupings. Their numeric values are contiguous with the space character, which can be considered a member of the group, as a word separator.

Transmission control

The transmission control characters were intended to structure a data stream, and to manage re-transmission or graceful failure, as needed, in the face of transmission errors.

The start of heading (SOH) character was to mark a non-data section of a data stream—the part of a stream containing addresses and other housekeeping data. The start of text character (STX) marked the end of the header, and the start of the textual part of a stream. The end of text character (ETX) marked the end of the data of a message. A widely used convention is to make the two characters preceding ETX a checksum or CRC for error-detection purposes. The end of transmission block character (ETB) was used to indicate the end of a block of data, where data was divided into such blocks for transmission purposes.

The escape character (ESC) was intended to "quote" the next character, if it was another control character it would print it instead of performing the control function. It is almost never used for this purpose today.

The substitute character (SUB) was intended to request a translation of the next character from a printable character to another value, usually by setting bit 5 to zero. This is handy because some media (such as sheets of paper produced by typewriters) can transmit only printable characters. However, on MS-DOS systems with files opened in text mode, "end of text" or "end of file" is marked by this Ctrl-Z character, instead of the Ctrl-C or Ctrl-D, which are common on other operating systems.

The cancel character (CAN) signalled that the previous element should be discarded. The negative acknowledge character (NAK) is a definite flag for, usually, noting that reception was a problem, and, often, that the current element should be sent again. The acknowledge character (ACK) is normally used as a flag to indicate no problem detected with current element.

When a transmission medium is half duplex (that is, it can transmit in only one direction at a time), there is usually a master station that can transmit at any time, and one or more slave stations that transmit when they have permission. The enquire character (ENQ) is generally used by a master station to ask a slave station to send its next message. A slave station indicates that it has completed its transmission by sending the end of transmission character (EOT).

The device control codes (DC1 to DC4) were originally generic, to be implemented as necessary by each device. However, a universal need in data transmission is to request the sender to stop transmitting when a receiver can't take more data right now. Digital Equipment Corporation invented a convention which used 19, (the device control 3 character (DC3), also known as control-S, or XOFF) to "S"top transmission, and 17, (the device control 1 character (DC1), aka control-Q, or XON) to start transmission. It has become so widely used that most don't realize it is not part of official ASCII. This technique, however implemented, avoids additional wires in the data cable devoted only to transmission management, which saves money. A sensible protocol for the use of such transmission flow control signals must be used, to avoid potential deadlock conditions, however.

The data link escape character (DLE) was intended to be a signal to the other end of a data link that the following character is a control character such as STX or ETX. For example a packet may be structured in the following way (DLE) <STX> <PAYLOAD> (DLE) <ETX>.

Miscellaneous codes

Code 7 (BEL) is intended to cause an audible signal in the receiving terminal.

Many of the ASCII control characters were designed for devices of the time that are not often seen today. For example, code 22, "synchronous idle" (SYN), was originally sent by synchronous modems (which have to send data constantly) when there was no actual data to send. (Modern systems typically use a start bit to announce the beginning of a transmitted word— this is a feature of asynchronous communication. Synchronous communication links were more often seen with mainframes, where they were typically run over corporate leased lines to connect a mainframe to another mainframe or perhaps a minicomputer.)

Code 0 (ASCII code name NUL) is a special case. In paper tape, it is the case when there are no holes. It is convenient to treat this as a fill character with no meaning otherwise. Since the position of a NUL character has no holes punched, it can be replaced with any other character at a later time, so it was typically used to reserve space, either for correcting errors or for inserting information that would be available at a later time or in another place.

Code 127 (DEL, a.k.a. "rubout") is likewise a special case. Its 7-bit code is all-bits-on in binary, which essentially erased a character cell on a paper tape when overpunched. Paper tape was a common storage medium when ASCII was developed, with a computing history dating back to WWII code breaking equipment at Biuro Szyfrów. Paper tape became obsolete in the 1970s, so this clever aspect of ASCII rarely saw any use after that. (However it should be noted that non-erasable Programmable ROMs are typically implemented as arrays of fusible elements, each representing a bit, which can only be switched one way, usually from one to zero. In such PROMs, the DEL and NUL characters can be used in the same way that they were used on punched tape: one to reserve meaningless fill bytes that can be written later, and the other to convert written bytes to meaningless fill bytes. For PROMs that switch one to zero, the roles of NUL and DEL are reversed; also, DEL will only work with 7-bit characters, which are rarely used today; for 8-bit content, the character code 255, commonly defined as a nonbreaking space character, can be used instead of DEL.) Some systems (such as the original Apples) converted it to a backspace. But because its code is in the range occupied by other printable characters, and because it had no official assigned glyph, many computer equipment vendors used it as an additional printable character (often an all-black "box" character useful for erasing text by overprinting with ink).

Many file systems do not allow control characters in the filenames, as they may have reserved functions.

See also

Notes and references

  1. ^ MS-DOS QBasic v1.1 Documentation. Microsoft 1987-1991.
  2. ^ [General Category Unicode 5.2, Chapter 4]
  3. ^ ASCII Characters at the Wayback Machine (archived October 28, 2009)

External links

Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Control Character —   [engl.], Steuerzeichen …   Universal-Lexikon

  • control character —    A nonprinting character with a special meaning. Control characters, such as Carriage Return, Line Feed, Bell, or Escape, perform a specific operation on a terminal, printer, or communications line. They are grouped together as the first 32… …   Dictionary of networking

  • control character — noun ASCII characters to indicate carriage return or tab or backspace; typed by depressing a key and the control key at the same time • Syn: ↑ASCII control character • Hypernyms: ↑ASCII character • Hyponyms: ↑backspace character …   Useful english dictionary

  • control character — valdymo ženklas statusas T sritis informatika apibrėžtis Valdymo veiksmą nurodantis ↑ženklas, esantis ženklų ↑koduotėje. Valdymo ženklai neturi grafinių vaizdų (↑glifų) ir nepriskiriami ↑rašmenims. Žymimi sutartiniais kelių raidžių žymėjimais –… …   Enciklopedinis kompiuterijos žodynas

  • control character — Computers. a character in a data stream that signals the device receiving the data to perform a particular control function, as changing the line spacing on a printer from single to double spaced. * * * …   Universalium

  • control character —    A character whose occurrence in a given context initiates, modifies, or stops a control operation …   IT glossary of terms, acronyms and abbreviations

  • control character — noun Computing a character that does not represent a printable character but serves to initiate a particular action …   English new terms dictionary

  • control character — noun A character which does not have a direct visual appearance as a glyph, but rather causes some other display action to occur, such as a transition to a new line. Examples are tab, carriage return, and line feed …   Wiktionary

  • control character — Any of 32 ASCII characters that do not print on your screen or printer. These characters are usually used to control your computer. See also CTRL …   Dictionary of telecommunications

  • ASCII control character — noun ASCII characters to indicate carriage return or tab or backspace; typed by depressing a key and the control key at the same time • Syn: ↑control character • Hypernyms: ↑ASCII character • Hyponyms: ↑backspace character …   Useful english dictionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”