Although most kinds of text file only contain text, it’s also possible to send additional information, usually related to the transmission or presentation of the text itself. This is commonly sent in the form of control codes or escape sequences.
All of the two or three-letter mnemonics in a computer’s character set represent control codes. Most modern computers and terminals, automatically generate these codes when you press a key, such as the Ctrl (Control) key, at the same time as a given ASCII character key.
The control codes defined by the ASCII standard are listed below:-
• Rarely used within data files
* Not available on a Mac OS computer
DEL, in the same way as code
127. Similarly, codes
159, when not used for characters, can have the same effect as codes
RS. Note that Ctrl-^ is often used to generate the
^character itself, whilst
RSis sometimes be obtained by pressing Ctrl-＞, with
USgenerated by pressing Ctrl-?. In some instances,
DELis sent as a special sequence of codes.
USwhen you press Ctrl at the same time as ⇠, ⇢, ⇡ or ⇣ respectively.
Control codes are rarely found inside modern documents, especially
EOT, as used in a communications link to mark the boundaries of text data,
NAK, which are used to check the presence of data passing over such a link, and
CAN, which maintain basic communications control. In addition,
SI can be used to instruct a printer to use double-width, compressed-width or an alternative character set,
DC4 can select other printer modes, whilst
US can be used as a form of punctuation for non-textual data.
Some software and computer systems use selected codes as follows:-
Ctrl-Q and Ctrl-S, are specifically used in a computer terminal to pause and resume long listings of text on the screen. You simply press Ctrl-S when you spot something you want to read and then press Ctrl-Q to continue the listing, or you can press Ctrl-C to abort the entire process.
Computer operating systems often use control codes for various purposes ‘behind the scenes’. For example, many of the keys on a Mac OS keyboard generate special character codes that are actually control codes. Similarly, the special font characters that appear in Classic Mac OS menus are identified by control codes, although these are unrelated to the original purposes of the codes.
The following table provides further details, including Mac OS symbols:-
|Hex||Dec||Name||Std ||Mac |
Standard coding systems don’t provide for sending instructions to another device, such as a printer or modem. However, such instructions can be accommodated inside an escape sequence, usually consisting of an
ESC control code (decimal
1B) followed by a string of data bytes. To be effective, each sequence must include the correct number of bytes.
The notation used for an escape sequence is quite simple. For example, the instruction
ESC ! BS is actually made up of
27) followed by
8). Sequences sometimes include control codes, as in, for example,
ESC EM R, where
EM is the control code.
Escape sequences can be used to accommodate non-standard keys on a keyboard where other control codes can’t be used. For example, a standard VT220 terminal can use the following sequences to accommodate special keys, including the function keys from F6 to F20, as found on modern keyboards:-
|Find||ESC [ 1 ~||F6||ESC [ 17 ~|
|Ins||ESC [ 2 ~||F7||ESC [ 18 ~|
|Rmv||ESC [ 3 ~||F8||ESC [ 19 ~|
|Sel||ESC [ 4 ~||F9||ESC [ 20 ~|
|Prev||ESC [ 5 ~||F10||ESC [ 21 ~|
|Next||ESC [ 6 ~||F11||ESC [ 23 ~|
|F12||ESC [ 24 ~|
|F13||ESC [ 25 ~|
|F14||ESC [ 26 ~|
|F15||ESC [ 28 ~|
|F16||ESC [ 29 ~|
|F17||ESC [ 31 ~|
|F18||ESC [ 32 ~|
|F19||ESC [ 33 ~|
|F20||ESC [ 34 ~|
Escape sequences can be used to control an older type of dot-matrix printer, although there is considerable variation in the interpretation of such codes, some of which operate with both an Epson (ESC/P) printer or an IBM-compatible printer. Other printer models also use some of these sequences or different codes of their own.
©Ray White 2004.