Английская Википедия:Caret notation

Материал из Онлайн справочника
Перейти к навигацииПерейти к поиску

Шаблон:Short description Шаблон:Refimprove Caret notation is a notation for control characters in ASCII. The notation assigns Шаблон:Code to control-code 1, sequentially through the alphabet to Шаблон:Code assigned to control-code 26 (0x1A). For the control-codes outside of the range 1–26, the notation extends to the adjacent, non-alphabetic ASCII characters.

Often a control character can be typed on a keyboard by holding down the Шаблон:Keypress 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 caret notation.

Description

The notation consists of a caret (Шаблон:Mono) 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 Шаблон:Mono through Шаблон:Mono. Seven ASCII control characters map outside the upper-case alphabet: 0 (NUL) is Шаблон:Mono, 27 (ESC) is Шаблон:Mono, 28 is Шаблон:Mono, 29 is Шаблон:Mono, 30 is Шаблон:Mono, 31 is Шаблон:Mono, and 127 (DEL) is Шаблон:Mono.

Examples are "Шаблон:Mono" for the Windows CR, LF newline pair, and describing the ANSI escape sequence to clear the screen as "Шаблон:Mono".

Only the use of characters in the range of 63–95 ("Шаблон:Mono") 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 ("Шаблон:Mono" through "Шаблон:Mono"). Also see the bar notation used by Acorn Computers, below.

History

The convention dates back to at least the PDP-6 (1964). A manual for the PDP-6 describes Шаблон:Keypress 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]

Use in software

Many computer systems allow the user to enter a control character by holding down [[Control key|Шаблон:Keypress]] and pressing the letter used in the caret notation. This is practical, because many control characters (e.g., EOT) cannot be entered directly from a keyboard. Although there are many ways to represent control characters, this correspondence between notation and typing makes the caret notation suitable for many applications.

Usually, the need to hold down Шаблон:Keypress is avoided, for instance lower-case letters work just like upper-case ones. On a US keyboard layout Шаблон:Keypress produces DEL and Шаблон:Keypress produces ^@. It is also common for Шаблон:Keypress to produce ^@.

Caret notation is used to describe control characters in output by many programs, particularly Unix terminal drivers and text file viewers such as [[more (command)|Шаблон:Mono]] and [[Less (Unix)|Шаблон:Mono]] commands. Although the use of control-codes is somewhat standard, some uses differ from operating system to operating system, or even from program to program. The actual meaning or interpretation of the individual control-codes is not prescribed by the caret notation, and although the ASCII specification does give names to the control-codes, it does not prescribe how software should respond to them.

Alternate notations Шаблон:Anchor

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 Шаблон:Code in place of the caret. For example, Шаблон:Code (pronounced "control em", the same as for the Шаблон:Code notation) is the carriage return character, ASCII 13. Шаблон:Code is the vertical bar character code 124, Шаблон:Code is character 127 as above and Шаблон:Code adds 128 to the code of the character that follows it, so Шаблон:Code is character code Шаблон:Nowrap.

See also

References

Шаблон:Reflist


Шаблон:CharacterEncoding-stub