How do you type Unicode characters using hexadecimal codes?

79

32

This is in Windows, but answers for other operating systems can be handy to others.

Most guides say something to the effect of "hold down the Alt key and type in the code on the keypad". This works fine for decimal codes (like 65 for 'A'), but not for hexadecimal codes (like U+0041 for 'A').

Some applicatons provide other facilities that will allow hexadecimal Unicode character codes to be typed and then transformed. Word allows you to type the code (such as 200f) and then convert it to Unicode by typing Alt-X.

I'm looking for a general method of doing this that will work with the standard input.

user939

Posted 2009-07-26T06:27:11.593

Reputation:

1This works fine for unicode characters that don't include hex chars A through F. should read: for decimal codes. There are plenty of hexadecimal numbers that don't use A-F. Like 10, which is not ten then... – Arjan – 2009-07-26T07:47:41.570

1That's useless to me when I need to type a u+23AF. – None – 2009-07-27T12:35:53.153

4

My point is: you cannot type things like u+0041 (hex 41, decimal 65) using the numeric keypad either (as one would then need to type 65 rather than 41) -- http://www.fileformat.info/info/unicode/char/0041 So, using the Alt-trick works fine for decimal codes, but not for hexadecimal codes.

– Arjan – 2009-07-27T13:08:15.383

1@Will: the "alt+NN..." method expects decimal, not hex notation of the character position. Unicode uses hex. So if you want to type what Unicode represents as "U+23AF" you need to convert hex==23AF into decimal==9135, and then type "alt+9135". That's the only general method there is on offer. *But:* You wanted character may still not appear as expect in the text field or document, if your currently selected font does not have the "U+23AF" place filled (or if it is not a Unicode font in the first place!). – Kurt Pfeifle – 2010-06-25T22:45:04.850

@Arjan: you do not type *hex* chars with the "alt+nnn" method. You do only type *decimal* character codes. That's why you cannot type even straight "U+1234" strings (which do not contain any of your loathed "a-f" characters) into your numeric keypad as "alt+1234", but you need to convert hex==1234 into dec==4660 and then type "alt+4660" before you (MAY) get what you want. So your statement "using the Alt-trick does not work for hexdecimal codes" nails the problem exactly, but you missed to understand it yourself :-) – Kurt Pfeifle – 2010-06-25T22:49:28.757

And for those who came here looking to disable Control + Shift + u this is discussed here.

– Samuel Harmer – 2018-08-18T10:14:15.547

Answers

23

harrymc's answer is good, providing you're able/allowed to change the registry settings.

If not, you can use the Windows Calculator Accessory to convert from hexadecimal to decimal. The default mode won't do this: XP and Vista have a "Scientific mode, whereas Windows 7, 8, 8.1 and 10 have a "Programmer" mode.

Select Hex base, and then type in your hexadecimal number. Then change to Dec base to see the equivalent value in decimal. That's the number you need to type into your numeric keypad while holding down the Alt key.

This might depend on the input language, and you might need to prefix a zero to the decimal value.

Mike Hanson

Posted 2009-07-26T06:27:11.593

Reputation: 519

Just like @Jukka mentioned, the page I linked to in my answer also suggests you'd need to prefix a zero, and that it depends on the input language.

– Arjan – 2015-12-11T16:12:14.757

you can also calculate with set /a in a command window ;-). To convert hex=4321 into decimal, just type set /a 4*16*16*16+3*16*16+2*16+1 and the result will show up as 17185 – Kurt Pfeifle – 2010-06-25T22:56:20.363

@JukkaK.Korpela, I have, for years, misunderstood that Alt+nnnn required four digits, and could never understand why Unicode decimal values >999 wouldn't work. It's because Alt+nnnn is really Alt+0nnn ... Alt+0nnnn. I could kiss you. – JMD – 2016-09-29T17:16:11.263

2This answer is wrong. Alt+0nnn (0-255) inputs a character from the system's ANSI codepage (e.g. 1252). The value entered is modulo 256 as mentioned above. Alt+nnn (0-255), without a leading zero, inputs a character from the system's OEM codepage (e.g. 437 or 850). However, the first 31 codes aren't the normal ASCII control characters, but are instead the glyphs that were displayed for these characters on 1980s PCs running DOS. In the Windows API, the latter corresponds to using the MB_USEGLYPHCHARS flag when decoding bytes to Unicode via MultiByteToWideChar. – Eryk Sun – 2017-10-09T16:48:05.827

this does not work - as other mentioned, it depends on selected codepage. Alt+0nnnn worked for me only in Word, anywhere else it fails. Note that the answer has many upvotes and marked as accepted, thus it is very misleading for people searching for the answer and trying hard to replicate your solution which simply does not work. – Mikhail V – 2018-08-06T02:02:09.917

3Alternatively, set /a 0x4321 will also display 17185. – Marcks Thomas – 2012-12-13T12:31:42.130

6The answer is misleading, because it does not mention that a leading zero is needed when using a decimal number outside the Ascii range (> 127). If you want to type U+23AF and therefore convert 23AF to decimal, 9135, and then try using Alt 9135, you get “»” (U+00BB). You need to to type Alt 09135 (using the numpad) to get the right character. – Jukka K. Korpela – 2013-09-09T04:52:16.100

8The method using decimal numbers depends on “input language” (as a Microsoft concept), so the results vary by system and program. For example, in most Windows programs, when the system language has been set to English or other Western language, only Windows Latin 1 characters can be typed this way. Any Alt 0n for n > 255 will then work “modulo 256”, i.e. with n reduced to range 0...255 by dividing by 256 and taking the remainder. – Jukka K. Korpela – 2013-09-09T05:06:31.733

41

Found this in How to enter Unicode characters in Microsoft Windows :

I tested this on Windows XP and Windows 2003. This method works regardless of any of your language settings, but is the most cumbersome to type:

  1. Press and hold down the Alt key.
  2. Press the + (plus) key on the numeric keypad.
  3. Type the hexidecimal unicode value.
  4. Release the Alt key.

Alas, this appears to require a registry setting. It was already set on my computer, but some readers report that this method didn't work for them, and this is probably why. If you don't know what the registry is, please don't try this. Under HKEY_CURRENT_USER\Control Panel\Input Method, set EnableHexNumpad to "1". If you have to add it, set the type to be REG_SZ.

You should log off then log on after this registry change, or even reboot.

harrymc

Posted 2009-07-26T06:27:11.593

Reputation: 306 093

+1 but a couple of things: (i)in Both Firefox and IE if the hex code you're trying to type contains a leeter corresponding to the Alt+[letter] shortcut for a menu, the menu drops down and you don't get your character (this break E&F on both, A on IE and B on Firefox, notepad works fine as does the winkey+R "run" box) ; (ii)REG_SZ may appear in the right-click new entry menu as "Registry String" – Chris H – 2015-06-19T09:04:04.707

Is this supposed to work in all applications? I got it to work in notepad, notepad++, Firefox and even Excel, but not in Word, Outlook, PowerPoint nor Lync. This is on W7. – Didier L – 2016-03-08T18:02:27.563

@DidierL: I would guess that it would work on applications that don't misuse keyboard functions. – harrymc – 2016-03-08T18:51:46.567

In fact in those applications it ignores the + and it only takes decimal values. But I can't get the decimal form to work in other applications, and it's annoying to have 2 different methods with 2 different values. I'm surprised this doesn't work properly in all MS Office applications. – Didier L – 2016-03-08T18:56:10.293

@DidierL: Office is not the world's most orderly designed software. If you are looking for a general method, I found the UnicodeInput utility and also the article standard ways to enter Unicode characters.

– harrymc – 2016-03-08T19:39:34.730

Thanks, I've been looking into the standard ways quite a lot recently, and I'd prefer to avoid the utility (likely to work but I'm not sure I will still be allowed to use it even at short-term). I was just hoping to have a confirmation of whether it should work in Office (2013). – Didier L – 2016-03-08T19:49:30.810

3Hi harrymc. How do I type in letters contained in hex? example: "" = 👉 - after I hit F alt menu command gets executed on windows. It doesn't fly with conversion to decimal (128073) not adding leading zeroes. – Matas Vaitkevicius – 2016-06-09T11:22:25.503

1if I don't know what the registry is, then I don't know how to try neither. – Vanuan – 2012-04-06T17:28:15.883

5If you don't know what the registry is, you shouldn't ever touch it. Ask someone you know for help. – Wug – 2013-04-17T18:07:44.507

17

On Mac OS X: open International in System Preferences, and in Input Menu select "Unicode Hex Input" to add this option to the input menu. Sounds obvious, but this is well hidden in the long list of languages, between Ukrainian and Vietnamese. When selected, hold down Option and type the 4 digit hex code.

Also on OS X: Calculator can be set to Programmer mode (Cmd-3), which allows for entering decimal, octal and hexadecimal codes, which are then displayed as ASCII or Unicode. However, Copy will give one the code, not the character equivalent(s). Anyone?

(For Windows, see How to enter Unicode characters in Microsoft Windows; for other input methods see Wikipedia.)

And here on Super User:

And to go into extremes:

Arjan

Posted 2009-07-26T06:27:11.593

Reputation: 29 084

9

In Ubuntu (and variants thereof, like LinuxMint) you can enter Unicode values by pressing Ctrl+Shift+u followed by the Unicode value and Enter, for example:

Ctrl+Shift+u 263a then Enter yields:

Text: ☺
Screenshot: alt text

You might be able to couple this with AutoHotkey for easier input, or possible input in Windows.

JMD

Posted 2009-07-26T06:27:11.593

Reputation: 4 427

2Unfortunately it only works in GTK+ applications. – Mechanical snail – 2012-11-28T00:25:39.773

2You can also hold down Ctrl-Shift while typing the code, which avoids having to press Enter afterwards. – Mechanical snail – 2012-11-28T00:27:14.580

1

I have found a better solution:

You can add accent marks to any preceding character using Unicode combining diacritical marks.

Unicode 0301 - 0308 are useful for Pinyin.

for example: "a" + [ctrl][shift][u] + 0301 [return] -> á.

The pinyin list: ó -> 0301; ò -> 0300; ō -> 0304; ŏ -> 0306; ö -> 0308;

see http://en.wikipedia.org/wiki/Combining_character#Unicode_ranges

– emf – 2013-02-01T04:22:50.027

5

I have written a small AutoHotkey based Unicode Input tool because I did not find a better solution. You can insert unicode characters with Shift+Ctrl+U.

Unicode dialog

Basically, it converts the entry to a unicode character and “types” it at cursor position.

It does not support 6-digit unicode characters. Also, if you have an input field where all text is selected on focus loss, all text will be overwritten (I think I remember an old Firefox version showed this behaviour).

As a reference, here the AutoHotkey source if you want to compile it by yourself:

#SingleInstance force
#Persistent
;Menu, Tray, icon, unicode.ico
Menu, Tray, nostandard ; Put the following menu items on top (default: bottom)
Menu, Tray, add, Info, InfoHandler, -10
Menu, Tray, add
Menu, Tray, standard ; Add default menu items at the bottom
return

InfoHandler:
MsgBox Press Shift+Ctrl+U to get an entry field for unicode points (see decodeunicode.org for a list).`n`nAuthor: Simon A. Eugster <simon.eu@gmail.com> / granjow.net
return

+^u::
InputBox, codepoint, Unicode code point, U+
if not ErrorLevel
    Send {U+%codepoint%}
return

Simon A. Eugster

Posted 2009-07-26T06:27:11.593

Reputation: 840

2

It also depends where you want to use the special characters. With MS Office apps, you don't have to resort to knowing the ASCII codes for certain characters -- for example, to type a diaresis (i.e., the two dots you see above some characters in words such as naïve), in Word/Outlook/etc you can hit Ctrl + ':' (i.e., Ctrl+Shift+;) followed by 'i'.

There's a list of shortcuts available at http://word.mvps.org/FAQs/General/InsertSpecChars.htm ... just scroll down to "International Characters".

I don't know whether any non-Office apps support similar shortcuts.

Chris J

Posted 2009-07-26T06:27:11.593

Reputation: 649

2

Linux (including Qt/KDE applications)

As JMD mentioned, you can hold down Ctrl-Shift, type u1f4a9, and release in order to type U+1F4A9 in GTK+ applications (including GNOME programs, Firefox, Chromium, and LibreOffice, even under KDE). Some programs also support typing in sequence Ctrl-Shift-U, 1, f, 4, a, 9, Enter.

Unfortunately, this doesn't work in Qt applications (including KDE programs, Mathematica, and VLC). For BMP characters, there is a Unicode IBus input method. To enable, open IBus preferences and add the "Other - unicode (m17n)" input method (the two packages ibus-m17n and ibus-qt4 must be installed). When the cursor is in a text area, activate the input method (using the IBus toolbar or the keyboard shortcut). While active, the input method lets you type Ctrl-Shift-U followed by 4 hex digits, to input the corresponding Unicode character. This only works for BMP characters, though.

(Tested under Ubuntu.)

Mechanical snail

Posted 2009-07-26T06:27:11.593

Reputation: 6 625

where can i find the IBus preferences? – anarcat – 2018-10-26T15:44:56.790

Doesn't work on KDE for me.. – Jack – 2013-05-22T01:17:48.200

1

Perhaps not exactly what you're asking, but it what I was looking for. On Windows 10, you can hit Win+. or Win+; to open an emoji browser:

enter image description here

As you can see in the above image, you can also search by simply typing.

Aske B.

Posted 2009-07-26T06:27:11.593

Reputation: 261

0

For the lazy ones, following the correct answer from harrymc, you can use the command below in the CMD shell to directly edit the registry:

REG ADD "HKEY_CURRENT_USER\Control Panel\Input Method" /v EnableHexNumpad /t REG_SZ /d 1

Also remember (as noted by harrymc) a logoff or reboot might be needed.

Gruber

Posted 2009-07-26T06:27:11.593

Reputation: 255

0

Here is an example how to type any Unicode character, it works only if the Windows Registry is modified as described at the end of this answer:

Press the keys Alt++20AC. That will input the Euro sign (Unicode character "U+20AC").

  • Press and hold down the Alt key.
  • Press the + (plus) key on the numeric keypad.
  • Type the hexadecimal Unicode value (20AC in the example above).
  • Release the Alt key.

It works at least in Windows 10, but has proved to work in many versions.

The list of hexadecimal Unicode values can be found at https://www.fileformat.info/info/unicode/index.htm, for instance.

The Windows registry (run regedit.exe) must be changed as follows:

Under the key HKEY_Current_User/Control Panel/Input Method, add a new String Value EnableHexNumpad and set its value to 1.

Sandra Rossi

Posted 2009-07-26T06:27:11.593

Reputation: 103

0

This works for me on Firefox on Windows 10 typing for example » which has Unicode character U+00BB.

  • Hold down ALT (and still hold)
  • Press +
  • Hold down CTRL and then type bb (leading zeroes can be left out)
  • Release CTRL and ALT

Using the additional CTRL prevents the menu bar to be activated.

Markus Zeller

Posted 2009-07-26T06:27:11.593

Reputation: 121