Alt code: Difference between revisions

Content deleted Content added
Tag: Reverted
Revert vandalism. You delete large chunks of contents. Your "mod-256" excuse doesn't fool me.
Line 13:
 
In the ASCII standard, the numbers 0-31 and 127 are assigned to [[Control character#In Unicode|control characters]], for instance, [[code point]] 7 is typed by {{keypress|Ctrl|G}}. While some (most?) applications would insert a [[Bullet (typography)|bullet]] character {{char|•}} (code point 7 on [[code page 437]]), some would treat this identical to {{keypress|Ctrl|G}} which often was a command for the program.{{citation needed|date=October 2020}}
 
Typing a number greater than 255 causes an [[integer overflow]], producing a character whose code is the input number [[modulo operator|modulo]] 256.<ref name="WannaBuildASnowman" />
 
==Windows==
 
The Alt codes had become so well known and memorized by users that Microsoft decided to preserve them in [[Microsoft Windows]], even though the OS features a newer and different set of code pages, e.g., [[CP1252]]. As such, Windows supports the following Alt code algorithm to support both of themalgorithms:
 
* The familiar Alt+### combination (where ### is from 0 to 255) retains the old [[MS-DOS]] behavior, i.e., generates characters from the legacy code pages now called "[[Windows code page#OEM code page|OEM code pages]]." For instance, the combination {{key press|Alt}}+{{key press|1}}{{key press|6}}{{key press|3}} would result in {{char|ú}} (Latin letter u with [[acute accent]]) which is at 163 in the OEM code page of CP437 or CP850.<ref name="WindowsAltAlgo" /> This did not work for characters not in the Windows Code Page (such as box-drawing characters).
* The new Alt+0### combination (which prefixes a zero to each Alt code), produces characters from the newer "[[Windows code page#ANSI code page|Windows code pages]]."{{efn|Microsoft initially referred to them as "ANSI" code pages, but later acknowledged that this as a misnomer.}} For example, {{key press|Alt}}+{{key press|0}}{{key press|1}}{{key press|6}}{{key press|3}} yields the character {{char|£}} (symbol for the [[pound sterling]]) which is at 163 in CP1252.<ref name="WindowsAltAlgo">{{Cite web |date=2016-07-22 |title=To input characters that are not on your keyboard |url=http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/lang_char_code_input.mspx |url-status=dead |archive-url=https://web.archive.org/web/20160722031546/http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/lang_char_code_input.mspx?mfr=true |archive-date=2016-07-22 |access-date=2022-12-30 |website=Microsoft }}</ref>
* The built-in Windows [[RichEdit]] control (and by extension, all apps that use it, e.g., [[WordPad]]) override the above behavior and instead accept Alt+#### where #### is a decimal [[Unicode]] code point between 0 to 65,535.<ref name="RichEdit">{{Cite web |last=Walker |first=Jim |display-authors=etal |title=About Rich Edit Controls |work=Windows App Development |publisher=Microsoft |via=[[Microsoft Learn]] |url=https://learn.microsoft.com/windows/win32/controls/about-rich-edit-controls |date=27 April 2022}}</ref> For instance, {{key press|Alt}}+{{key press|9}}{{key press|7}}{{key press|3}}{{key press|1}} in WordPad produces the {{unichar|2603}}.
 
===Overflow behavior===
==Unicode==
Later versions of Windows and applications such as Microsoft Word supported Unicode. As Unicode included all the characters in the MSDOS code pages, this had the immediate benefit that all the old MSDOS Alt combinations worked (such as the line-drawing characters), not just the ones that existed in the Windows Code Page.
 
InAs thestated IBMabove, PCthe Biosvalid typingvalue for an Alt code greater(except thanthe RichEdit cases) is between 0 to 255. producedHowever, the sameuser asmay thatbreak this convention and type a larger number. In this case, Windows interprets all numbers greater than 255 [[Modulo operator|modulo]] 256.<ref name="WannaBuildASnowman">{{Cite web |first=Raymond |last=Chen |title=The history of Alt+number sequences, and why Alt+9731 sometimes gives you a heart and sometimes a snowman |work=The Old New Thing |publisher=Microsoft |date=2 July 2024 |url=https://devblogs.microsoft.com/oldnewthing/20240702-00/?p=109951}}</ref> SomeIn applicationscomputer retainedscience, this behavior, whileis others (in particular applications using the Windowscalled [[RichEdit]]integer control, such as [[WordPadoverflow]] and [[PSPad]]) made numbers from 256 to 65,535 produce the corresponding Unicode character.<ref name="RichEdit">{{Cite web |last=Walker |first=Jim |display-authors=etal |title=About Rich Edit Controls |work=Windows App Development |publisher=Microsoft |via=[[Microsoft Learn]] |url=https://learn.microsoft.com/windows/win32/controls/about-rich-edit-controls |date=27 April 2022}}</ref> For instance, {{key press|Alt}}+{{key press|9}}{{key press|7}}{{key press|3}}{{key press|1}} in WordPad produces the {{unichar|2603}}. If the Windows Code Page was set to CP1252 then all Unicode characters except [[C0 and C1 control codes|control characters]] could be typed this way.
 
Since the Windows RichEdit control implements a different Alt code algorithm that supports [[Unicode]] characters,<ref name="RichEdit" /> integer overflow occurs after 65,535, not 255, i.e., RichEdit interprets them modulo 65,536.<ref name="WannaBuildASnowman" />
==Alternatives==
 
===Hexadecimal Alt codes===
Because most Unicode documentation and tables show the code points in [[base 16|hex]], not decimal, a variation of Alt codes was developed to allow the typing of numbers in hex (using the main keyboard for {{keypress|A}}–{{keypress|F}}). To enable it, a user must set or create a string type ({{code|REG_SZ}}) value called <code>EnableHexNumpad</code> in the [[Windows Registry|registry]] key <code>HKEY_CURRENT_USER\Control&nbsp;Panel\Input&nbsp;Method</code>, assign the value data <code>1</code> to it, and then reboot or log out/in. A leading {{keypress|+}} then indicates hex input, for example {{key press|Alt|+}}{{key press|1|1|B|chain=}} will produce {{char|ě}}&nbsp;(e with [[caron]]).
 
Because most Unicode documentation and tablesthe [[Character Map (Windows)|Character Map]] utility show the code points in [[base 16|hex]], not decimal, a variation of Alt codes was developed to allow the typing of numbers in hex (using the main keyboard for {{keypress|A}}–{{keypress|F}}). To enable it, a user must set or create a string type ({{code|REG_SZ}}) value called <code>EnableHexNumpad</code> in the [[Windows Registry|registry]] key <code>HKEY_CURRENT_USER\Control&nbsp;Panel\Input&nbsp;Method</code>, assign the value data <code>1</code> to it, and then reboot or log out/in. A leading {{keypress|+}} then indicates hex input, for example {{key press|Alt|+}}{{key press|1|1|B|chain=}} will produce {{char|ě}}&nbsp;(e with [[caron]]).
There are many [[Unicode input|other ways]] of typing Unicode characters, such as the [[Character Map (Windows)|Character Map]] utility and foreign keyboard layouts.
 
== Other operating systems ==
Line 40 ⟶ 42:
==Limitations==
If {{key press|[[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, {{keypress|Alt|4}} can be taken as {{keypress|Alt|←}}, causing a web browser to go back one page.
 
==Alternatives==
 
{{Main|Input method|Unicode input}}
[[Windows NT 3.1]] introduced the [[Character Map]] utility that became a mainstay of the OS. The utility enables users to visually browse a typeface and copy its characters.
 
[[Windows 8]] introduced the touch keyboard, an on-screen keyboard for touchscreen devices without physical keyboards. The touch keyboard can input more characters than most physical keyboards. [[Windows 10]] greatly enhanced the number of characters it can type. Also introduced in Windows 10 is the emoji panel, invoked with the {{keypress|Win|.}} combination. It allows users to find and type emoji and Unicode symbols.
 
[[Microsoft Word]] comes with an Input Symbol command (similar to Character Map), a Unicode input method, and an auto-correct feature for converting rudimentary notations to their official Unicode equivalents.
 
== List of codes ==