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

Emacs: Set Default File Encoding

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 by Lisp Code.

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”.

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, then 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

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Emacs Tutorial

Quick Start

Manage Windows



Find Replace




Rectangle Edit

Line Wrap


View Special File

Editing Brackets

Org Mode


Emacs Efficiency