Emacs: Unicode Tutorial

By Xah Lee. Date: . Last updated: .

First see: Unicode Basics: Character Set, Encoding, UTF-8, Codepoint

screenshot 20210828162214 KhxkS
emacs showing Unicode chars. You can download this text here: unicode.txt.

Set default file encoding

Put this in your emacs init file:

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

To find possible valid values, type Alt+x set-language-environment, then press Tab to show all possible valid values. Press Ctrl+g to cancel. Then, Alt+x switch-to-buffer to “*Completions*”.

Alt+x list-coding-systems to see possible valid values.

See also:

Set a key to insert unicode char

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 lists of math symbols and Unicode search, see Unicode Search 😄

Use abbrev to insert Unicode char

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 Alt+x eval-region. [see Evaluate Emacs Lisp Code]

Now, type ar , it will become .

For detail, see: Emacs: Abbrev Mode.

If you type math symbols often, use Emacs: Xah Math Input Mode, xah-math-input.el.

Insert letter with accent marks é

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

If you need to type these chars often,

Alt+x set-input-method then type “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)

Insert a Unicode character by name

Alt+x 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, Alt+x insert-char, then type *arrow then Tab, then emacs will show all chars with “arrow” in their names.

Note: insert-char was ucs-insert in emacs 24.3 or before.

Insert a Unicode character by its hexadecimal value

Alt+x insert-charCtrl+x 8 Enter】, then the hexadecimal of the Unicode.

For example, try insert . Its hexadecimal value is “2192”.

Insert a Unicode character by its decimal value

Alt+x insert-charCtrl+x 8 Enter】, then type “#10r” followed by the decimal codepoint. e.g. #10r8594

For example, try insert . Its coidpoint in decimal is “8594”.

A more convenient way is to install Emacs: Xah Math Input Mode, xah-math-input.el.

Type Chinese

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

To switch back to normal input, Alt+x toggle-input-methodCtrl+\】.

For detail, see: Emacs Chinese Input.

Find out current input method

Alt+x describe-variable then type current-input-method.

Find a character's hexadecimal value or name

Place cursor on the character then call describe-char.

emacs find unicode info describe-char 2015-09-20
M-x describe-char

For a mode to make this easier, see xub Unicode Browser mode for Emacs.

Update emacs unicode data database

Unicode has a new version every year. Emacs's unicode info for describe-char may not be up-to-date. (it doesn't know the new character).

You can make emacs use the latest unicode data.

Download the latest UnicodeData.txt at https://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt

Put that file in your emacs init dir. Put this in your emacs init file:

(when (file-exists-p "~/.emacs.d/UnicodeData.txt")
  (setq describe-char-unicodedata-file "~/.emacs.d/UnicodeData.txt"))

Get emacs to display missing emoji 😸

See: Emacs: Font Setup.

Unicode Characters Search

Unicode Search 😄

Unicode and Font

Spent a few hours here?

Emacs Tutorial

Emacs Init

Emacs Keys

Elisp Basics

Elisp Examples

Elisp Advanced

Elisp Write Major Mode

Emacs Tutorial

Quick Start

Manage Windows



Find Replace




Rectangle Edit

Line Wrap


View Special File

Editing Brackets

Org Mode


Emacs Efficiency