Caret notation
Caret notation is a notation for control characters in ASCII. The notation assigns to control-code 1, sequentially through the alphabet to assigned to control-code 26. For the control-codes outside of the range 1–26, the notation extends to the adjacent, non-alphabetic ASCII characters; for example is used for control-code 0.
Often a control character can be typed on a keyboard by holding down the and typing the character shown after the caret. The notation is often used to describe keyboard shortcuts even though the control character is not actually used.
The meaning or interpretation of, or response to the individual control-codes is not prescribed by the letters in caret notation.
Description
The notation consists of a caret followed by a single character. The character has the ASCII code equal to the control code with the bit representing 0x40 reversed. A useful mnemonic, this has the effect of rendering the control codes 1 through 26 as through. Seven ASCII control characters map outside the upper-case alphabet: 0 is, 27 is, 28 is, 29 is, 30 is, 31 is, and 127 is.Examples are "" for the Windows CR, LF newline pair, and describing the ANSI escape sequence to clear the screen as "".
Only the use of characters in the range of 63–95 is specifically allowed in the notation, but use of lower-case alphabetic characters entered at the keyboard is nearly always allowed – they are treated as equivalent to upper-case letters. When converting to a control character, except for '?', masking with 0x1F will produce the same result and also turn lower-case into the same control character as upper-case.
There is no corresponding version of the caret notation for control-codes with more than 7 bits such as the C1 control characters from 128–159. Some programs that produce caret notation show these as backslash and octal. Also see the bar notation used by Acorn Computers, below.
History
The convention dates back to at least the PDP-6 from Digital Equipment Corporation and DEC's operating system for it. A manual for the PDP-6 describes as printing ↑C, i.e., a small superscript upwards arrow before the C. In the change from 1961 ASCII to 1968 ASCII, the up arrow became a caret. The PDP-6's successor, the PDP-10, and its operating system used the same convention. Some non-DEC operating systems for PDP-10s, such as TENEX and ITS, adopted the convention as well.The same convention was used in DEC's operating systems for its PDP-11 minicomputer, such as RT-11, RSTS, and RSX-11M.
Earlier versions of Unix did not use the caret convention to display non-printing control characters, although the command accepted caret notation when setting the character-erase and line-kill characters. 4BSD added a mode in which control characters are echoed using caret notation; this has been adopted by modern Unix-like systems as.
Use in software
Caret notation is used to describe control characters in output by many programs, especially on Unix. They can be seen when echoing characters as the user types them as input, and showing the contents of files in a text editor or with the [more (command)|] and [Less (Unix)|] commands.Many terminals and terminal emulators allow the user to enter a control character by holding down and typing the caret notation letter. Many control characters otherwise cannot be entered directly from a keyboard. Usually, the need to hold down is avoided, for instance lower-case letters work just like upper-case ones. On a US keyboard layout produces DEL and produces ^@. It is also common for to produce ^@.
This correspondence has affected shortcuts used even in modern software. For instance it might be tempting to make mean "Help" but this is the same code as so other shortcuts for Help were devised.