Alt code

On personal computers using Microsoft operating systems, characters that do not have a dedicated key may nevertheless be entered using the Alt numpad input method or Alt code. This is done by pressing and holding the Alt key while typing a number that identifies the character, using the keyboard's numeric keypad, then releasing Alt. Similar or extended forms of this feature are also available in some other operating systems.

Often this is the best or only method many Windows users know for entering some characters.

History and description

MS DOS

On IBM PC compatible personal computers from the 1980s, the BIOS allowed the user to hold down the Alt key and type a decimal number on the keypad. It would place the corresponding code into the keyboard buffer so that it would look (almost) as if the code had been entered by a single keystroke. Applications reading keystrokes from the BIOS would behave according to what action they associate with that code. Some would interpret the code as a command, but often it would be interpreted as a code to be placed on the screen at the location of the cursor, thus displaying the corresponding 8-bit character from the current code page. On the original IBM PC this was CP437.[lower-alpha 1]. In most cases typing a number greater than 255 produced the remainder after the number is divided by 256.

Some Eastern European, Arabic and Asian computers used other hardware code pages, and MS-DOS was able to switch between them at runtime with commands like KEYB, CHCP or MODE. This causes the Alt combinations to produce different characters (as well as changing the display of any previously-entered text in the same manner). A common choice in locales using variants of the Latin alphabet was CP850, which provided more Latin character variants. (There were, however, many more code pages; for a more complete list, see code page).

PC keyboards designed for non-English use included other methods of inserting these characters, such as national keyboard layouts, the AltGr key or dead keys, but the Alt key was the only method of inserting some characters and the only method that was the same on all machines, so it remained very popular. This input method is emulated by many pieces of software (such as later versions of MS-DOS and Windows) that do not use the BIOS keyboard decoding.

In the ASCII standard, the numbers 0-31 and 127 are assigned to control characters, but MS DOS did not interpret the numbers this way. For instance, code point 7 is assigned to BEL. However with some applications, Alt+7 may yield a bullet character (code point 7 on code page 437), but in others would treat this input as identical to Ctrl+G (which on a terminal produces a control character with a value of 7).

Windows

The Alt codes had became so well known and memorized by users that Microsoft decided to preserve them, even though it used a new and different set of code pages for Windows, such as CP1252. The old code pages were called OEM code pages; the new ones are called Windows code pages,[lower-alpha 2] The familiar Alt+number combinations produced codes from the OEM code page (for example, CP437)[lower-alpha 3], matching the results from MS-DOS. But prefixing a leading zero (0) to the number (usually meaning 4 digits) produced the character specified by the newer Windows code page, allowing them to be typed as well.

For instance, the combination Alt+163 would result in ú (Latin letter u with acute accent) which is at 163 in the OEM code page of CP437 or CP850, while Alt+0163 yields the character £ (symbol for the pound sterling) which is at 163 in CP1252.[lower-alpha 4].

The numbers 0 –31 and 127 are control characters in the Windows code pages. Typing these numbers with a leading zero is ignored.

Before Unicode was introduced, most Windows software could only create text using the repertoire of characters available in a single code page. Characters that did not exist in that page (such as a line-drawing graphic from the OEM page when the software was using the Windows code page) could not be inserted, and either were ignored or produced an unexpected character. Modern software uses Unicode, which assigns numbers (code points) to all the characters in all the code pages. The software has access to the glyphs corresponding to all the code points in the supported fonts, so it can produce the character specified by any Alt code less than 256 whether zero-prefixed or non-zero-prefixed.

Transition to Unicode

When Windows later transitioned to Unicode, there was a desire to extend the Alt codes to allow entry of any Unicode code point. Some applications (RichEdit-based) like Word 2010, Wordpad, and PSPad will display the characters corresponding to many Alt codes larger than 255 when they have fonts available with the relevant glyphs. Other Windows applications, including Notepad, Chrome, Firefox, and Microsoft Edge interpret all numbers greater than 255 modulo 256.

Numbers less than 256 work as before, using the OEM code page. However, if the number is prefixed with 0 and the Windows code page is CP1252, all the displayable characters encoded by the first 256 Unicode code points are also generated by their decimal Unicode code points. The C0 controls (decimal 0 –31) don't work, but most of the C1 codes (128 –159) are used (contrary to ISO standard ISO/IEC 8859) to encode useful symbols. For example, Alt+0150 and Alt+0151 produce the en and em dashes, and , respectively.

Most Unicode documentation and the Character Map accessory show the code points in hex, not decimal, making decimal input inconvenient. So a method was developed to enter Unicode in Windows using the hexadecimal code point. To enable it, a user must set or create a string type (REG_SZ) value called EnableHexNumpad in the registry key HKEY_CURRENT_USER\Control Panel\Input Method, assign the value data 1 to it, and then reboot or log out/in. A leading + then allows entry of a hex Unicode value (using the main keyboard for AF) For example, Alt++11B will produce ě (e with caron).

Many applications, including Word, Wordpad, Excel, and LibreOffice, support a simpler method that works for many characters: typing the hex digits first (inserting them into the document) and then typing Alt+X to change them into the matching Unicode character.

Problems

If Num lock is disabled, attempting an Alt code may cause unexpected results in some applications, due to the controls used on the same key. For example, Alt+4 can be taken as Alt+, causing a web browser to go back one page.

Many laptops do not have a separate numeric keypad, but some may provide numpad input by holding a modifier key (typically labelled "Fn"); thus one must press and hold both Alt and Fn keys while entering the character code.

Other operating systems

The Alt key method does not work on Chrome OS, Mac OS, Linux or other operating systems and there is no readily-accessible evidence of interest in replicating it, due to its including the 1980s IBM PC character encoding as part of its definition. However, numeric entry of Unicode characters is possible in most Unix or Unix-like OSs by typing Ctrl+⇧ Shift+U, (release) then the hex number, then the space bar or enter key. For example,

Alternatives

Alternative systems exist for users to make characters without selecting them by number, for example using a popup window that lets a user choose the desired character by clicking on it. Examples include the Windows Character Map or the Insert Character facility in MsOffice. See Unicode input for more.

See also

Notes

  1. See article CP437 for a list of the numbers accepted
  2. Initially these were called "ANSI" code pages, but Microsoft has acknowledged that this was a misnomer.
  3. Simplifying a bit by not taking 16-bit DBCS code pages into account here.
  4. See CP1252 for a list of these zero-prefixed alt combinations

References

    This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.