Emacs: Unicode Tutorial

By Xah Lee. Date: . Last updated: .

This page is a tutorial on using emacs and Unicode. ➢ for example: how to type math symbol, how to switch input methods, finding Unicode character name or code point, how to set file encoding, ….

Carbon emacs 22 Unicode
A screenshot of emacs window showing Unicode chars. You can download this text here: unicode.txt. (not exactly the same)

How to set default file encoding?

Put this in your emacs init:

(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)

UTF-8 is becoming the standard for file encoding. I recommend it highly.

See also:

Typing Unicode Characters

How to set a key to insert math symbol?

For example, put the following code in your emacs init file.

;; set keys to insert math symbol
(define-key key-translation-map (kbd "<f9> p") (kbd "φ"))
(define-key key-translation-map (kbd "<f9> x") (kbd "ξ"))
(define-key key-translation-map (kbd "<f9> i") (kbd "∞"))
(define-key key-translation-map (kbd "<f9> <right>") (kbd "→"))

For detail, see: Emacs: Remapping Keys Using key-translation-map.

For OS-wide, see: How to Create a APL or Math Symbols Keyboard Layout.

For list of math symbols and Unicode search, see Unicode Characters Search ☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥

How to use abbrev to input Unicode chars?

Put the following in your emacs init file:

(define-abbrev-table 'global-abbrev-table '(
    ("alpha" "α")
    ("inf" "∞")
    ("ar" "→")

(abbrev-mode 1) ; turn on abbrev mode

Select the code above and call eval-region. 〔➤see Emacs: How to Evaluate Emacs Lisp Code

Now, type ar , it will become .

For detail, see: Emacs: Abbrev Mode Tutorial.

If you type math symbols often, use Emacs: xah-math-input.el.

How to type this character é ?

Here's a table on how to type these chars:

CharacterKey Press
éCtrl+x 8 ' e
àCtrl+x 8 ` a
îCtrl+x 8 ^ i
ñCtrl+x 8 ~ n
üCtrl+x 8 " u

To see all characters you can type this way, press 【Ctrl+x 8 Ctrl+h】. Example: ¿ ¡ ¢ £ ¥ ¤ § ¶ ® © ª «» × ÷ ¬ ° ± µ ÀÁÂÃÄÅÆ Ç ÈÉÊË ÌÍÎÏ ÐÑ ÒÓÔÕÖ ØÙÚÛÜÝÞß àáâãäåæç èéêë ìíîï ðñòóôõö øùúûüýþÿ.

If you need to type these chars often, call set-input-method and give “latin-9-prefix”. That will allow you to type these chars without typing 【Ctrl+x 8】 first.

(Emacs's “latin-9-prefix” corresponds to the char set ISO 8859-9)

A better way is to install Emacs: xah-math-input.el. With that, to type é, just type e' followed by a activation key.

How to insert a Unicode character by name?

Call insert-charCtrl+x 8 Enter ↵】, then the name of the Unicode. For example, try insert . Its name is “RIGHTWARDS ARROW”.

You can use asterisk * to match chars. For example, call insert-char, then type *arrow then Tab ↹, then emacs will show all chars with “arrow” in their names.

Note: in emacs 24, ucs-insert is renamed to insert-char. ucs-insert is obsolete since 24.3.

How to insert a Unicode character by its hexadecimal value?

Call insert-charCtrl+x 8 Enter ↵】, then the hex of the Unicode. For example, try insert . Its hex value is “2192”.

How to insert a Unicode character by its decimal value?

Call eval-expression, then type (insert-char 8594) for .

A more convenient way is to install Emacs: xah-math-input.el.

Typing Chinese or Non-Latin Languages

How to type Chinese?

Call set-input-method, then give value chinese-py. (“chinese-py” is a basic Chinese pinyin input method.)

To switch back, call toggle-input-methodCtrl+\】.

For detail, see: Emacs Chinese Input for Studying Chinese.

How to find out what's the current input method?

Call describe-variableCtrl+h v】 then type current-input-method.

Finding Info About a Character

I have this character α on the screen. How to find out its Unicode's hex value or name?

You can find out a char's info by placing your cursor on the character then call describe-char.

emacs find unicode info describe-char 2015-09-20
Output of describe-char in Emacs 24.5.

See also: xub Unicode Browser mode for Emacs.

How to get emacs to display missing emoticon 😸?

See: Emacs: Set Font.

See also, list of unicod emoticons at Unicode Emoticons, Faces 😃 😄 😱 😸 👸 👽 👍.

Emacs File/Character Encoding/Decoding FAQ

Emacs File/Character Encoding/Decoding FAQ

Emacs Lisp: Unicode Representation in String

Emacs Lisp: Unicode Representation in String

More About Unicode

Unicode Characters Search ☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥

Unicode Characters Search ☢ ☯ ☭ ∑ ∞ ♀ ♂ ♥

Like it? Buy Xah Emacs Tutorial. Thanks.