Caret notation

From Wikipedia, the free encyclopedia

Template:Short description Template:Refimprove Caret notation is a notation for control characters in ASCII. The notation assigns ^A to control-code 1, sequentially through the alphabet to ^Z 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 Script error: No such module "key". 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 (as in "type ^X to cut the text").

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 (Page Template:Mono/styles.css has no content.^) followed by a single character (usually a capital letter). 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 Page Template:Mono/styles.css has no content.^A through Page Template:Mono/styles.css has no content.^Z. Seven ASCII control characters map outside the upper-case alphabet: 0 (NUL) is Page Template:Mono/styles.css has no content.^@, 27 (ESC) is Page Template:Mono/styles.css has no content.^[, 28 (FS) is Page Template:Mono/styles.css has no content.^\, 29 (GS) is Page Template:Mono/styles.css has no content.^], 30 (RS) is Page Template:Mono/styles.css has no content.^^, 31 (US) is Page Template:Mono/styles.css has no content.^_, and 127 (DEL) is Page Template:Mono/styles.css has no content.^?.

Examples are "Page Template:Mono/styles.css has no content.^M^J" for the Windows CR, LF newline pair, and describing the ANSI escape sequence to clear the screen as "Page Template:Mono/styles.css has no content.^[[3J".

Only the use of characters in the range of 63–95 ("Page Template:Mono/styles.css has no content.?@ABC...XYZ[\]^_") 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 (0x80–0x9F). Some programs that produce caret notation show these as backslash and octal ("Page Template:Mono/styles.css has no content.\200" through "Page Template:Mono/styles.css has no content.\237"). Also see the bar notation used by Acorn Computers, below.

History

The convention dates back to at least the PDP-6 (1964) from Digital Equipment Corporation (DEC) and DEC's operating system for it. A manual for the PDP-6 describes Script error: No such module "key". as printing C, i.e., a small superscript upwards arrow before the C.[1] In the change from 1961 ASCII to 1968 ASCII, the up arrow became a caret.[2] 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[3] and ITS,[4] adopted the convention as well.

The same convention was used in DEC's operating systems for its PDP-11 minicomputer, such as RT-11,[5] RSTS,[6][7] and RSX-11M.[8]

Earlier versions of Unix did not use the caret convention to display non-printing control characters, although the Page Template:Mono/styles.css has no content.stty command accepted caret notation when setting the character-erase and line-kill characters.[9] 4BSD added a Page Template:Mono/styles.css has no content.ctlecho mode in which control characters are echoed using caret notation;[10] this has been adopted by modern Unix-like systems as Page Template:Mono/styles.css has no content.echoctl.[11][12][13][14][15][16]

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 Page Template:Mono/styles.css has no content.more and Page Template:Mono/styles.css has no content.less commands.

Many terminals and terminal emulators allow the user to enter a control character by holding down Script error: No such module "key". and typing the caret notation letter. Many control characters (e.g., EOT) otherwise cannot be entered directly from a keyboard. Usually, the need to hold down Script error: No such module "key". is avoided (for instance, lower-case letters work identically to upper-case ones). On a US keyboard layout, Script error: No such module "key". produces DEL and Script error: No such module "key". produces ^@. It is also common for Script error: No such module "key". to produce ^@.

This correspondence has affected shortcuts used even in modern software. For instance, it may be tempting to make Script error: No such module "key". mean "Help", but this is the same code as Script error: No such module "key"., so other shortcuts for Help were devised.

Alternate notations

The GSTrans string processing API on the operating systems for the Acorn Atom and the BBC Micro, and on RISC OS for the Acorn Archimedes and later machines, use the vertical bar character | in place of the caret. For example, |M (pronounced "control em", the same as for the ^M notation) is the carriage return character, ASCII 13. || is the vertical bar character code 124, |? is character 127 as above and |! adds 128 to the code of the character that follows it, so |!|? is character code 128 + 127 = 255.

See also

References

Page Template:Reflist/styles.css has no content.

  1. ^ Page Module:Citation/CS1/styles.css has no content.PDP-6 Timesharing Software (PDF). Digital Equipment Corporation. p. 4.
  2. ^ Page Module:Citation/CS1/styles.css has no content.Haynes, Jim (2015-01-13). "First-Hand: Chad is Our Most Important Product: An Engineer's Memory of Teletype Corporation". Engineering and Technology History Wiki (ETHW). Archived from the original on October 31, 2016. Retrieved 2016-10-31. There was the change from 1961 ASCII to 1968 ASCII. Some computer languages used characters in 1961 ASCII such as up arrow and left arrow. These characters disappeared from 1968 ASCII. We worked with Fred Mocking, who by now was in Sales at Teletype, on a type cylinder that would compromise the changing characters so that the meanings of 1961 ASCII were not totally lost. The underscore character was made rather wedge-shaped so it could also serve as a left arrow.
  3. ^ Page Module:Citation/CS1/styles.css has no content.TENEX Executive Manual for Users (PDF). Bolt, Beranek, and Newman. April 1973. pp. 6, 17–18.
  4. ^ Page Module:Citation/CS1/styles.css has no content."ITSTTY".
  5. ^ Page Module:Citation/CS1/styles.css has no content.RT-11 System Reference Manual (PDF). Digital Equipment Corporation. September 1973. p. 2-3. DEC-11-ORUGA-A-D.
  6. ^ Page Module:Citation/CS1/styles.css has no content.PDP-11 Resource Time-Sharing System (RSTS-11) User's Guide BASIC-Plus Programming Language (PDF). Digital Equipment Corporation. September 1973. p. 1-6. PL-11-71-01-01-A-D.
  7. ^ Page Module:Citation/CS1/styles.css has no content.RSTS-11 System User's Guide (PDF). Digital Equipment Corporation. July 1975. pp. 3-2 – 3-3. DEC-11-ORSUA-D-D.
  8. ^ Page Module:Citation/CS1/styles.css has no content.RSX-11M Operator's Procedures Manual (PDF). Digital Equipment Corporation. 1975. pp. 2-2 – 2-4. DEC-11-OMOGA-B-D.
  9. ^ Template:Man
  10. ^ stty(1)4BSD Unix Programmer's Manual
  11. ^ Template:Man
  12. ^ Template:Man
  13. ^ Template:Man
  14. ^ Template:Man
  15. ^ Template:Man
  16. ^ stty - AIX Commands Manual


Template:Asbox