Starting with GNU Emacs 23, there is relatively complete Unicode support. See the Emacs manual for more information. Some starter tips about entering (inserting) Unicode characters:
‘ucs-insert’for Emacs before version 24) (
‘C-x 8 RET’), which lets you either enter a Unicode code point or complete against the Unicode character name. It can be slow, because there are many candidate characters to choose from.
‘ucsc-insert’, a replacement for
‘ucs-insert’for Emacs before version 24) — bind it to
‘C-x 8 RET’. It does the same thing, except that with a negative prefix argument (for which
‘ucs-insert’does nothing) it automatically creates such a command.
‘ucs-make-commands’, which defines a whole set of such commands. You pass it a regexp, which is matched against all Unicode character names (in
‘ucs-names’). An insertion command is created for each of the characters whose name matches.
‘SPC’characters in the character names are replaced by hyphens (
‘-’), and the command names are lowercase, not uppercase like the character names.
Assume you have an UTF-8 file, but your locale uses ISO-8859-1 (Latin-1). Typically when you open the file, it will be garbled, depending on its exact contents and your setup. Auto-detection of UTF-8 is effectively disabled by default in GNU Emacs 21.3 and below. You can prefer it just below your preferred coding system by specifying utf-8 with
‘M-x prefer-coding-system’ and then repeating the command to replace your most preferred coding system at the front of the priority list (
Otherwise, you need to tell Emacs that the file is in UTF-8 before reading it by prefixing your
‘C-x C-f’ or
‘C-x C-v’ command with
‘C-x C-m c utf-8 RET’. It should display correctly.
To edit the file, just type. If you need to insert characters that your keyboard does not have, you need an InputMethod. Choose one using
‘M-x set-input-method’. Once you have an input method active, toggle it on and off using `C-\’.
To describe input methods, use
I also bind
‘set-input-method’ as follows:
(global-set-key (kbd "C-x C-m i") 'set-input-method)
C-\ can also set input method. --XueFuqiao
If you always prefer UTF-8 to ISO-8859-1, you can use this:
This function, bound to a key, will allow you to enter unicode characters by code point: handy if you do not know which input method to use, but can find the code point of the character:
(defun unicode-insert (char) "Read a unicode code point and insert said character. Input uses `read-quoted-char-radix'. If you want to copy the values from the Unicode charts, you should set it to 16." (interactive (list (read-quoted-char "Char: "))) (ucs-insert char))
You can find charts of the characters here: http://www.unicode.org/charts/
If you use them, you might want to use the following setting to enter hexadecimal using C-q:
(setq read-quoted-char-radix 16)
‘M-x customize-option RET auto-coding-regexp-alist RET’. You can then insert items such as
<meta\b[^>]*\bcontent="text/html; charset=UTF-8"[^>]*> utf-8 <\?xml\b[^>]*\bencoding="utf-8"[^>]*\?> utf-8
There may be a better way – these patterns are a little too rigid for reliable identification of all Unicode documents. At least you can edit them to cope with the set of documents you normally deal with.
You can use
‘file-coding-system-alist’ to specify that, say, .xml and .utf8 files are utf-8-encoded.
Some CJK (Chinese, Japanese, Korean) characters have been “unified” in the Unicode standard. What does that mean? The Unicode FAQ by Markus Kuhn  says:
Some compilations of Chinese characters alone can already take 50000 positions. Putting them all in the BMP would not leave enough space for all the other characters there, so Unicode unified sets of character shapes that have the same meaning but vary in inessential detail. The Han Unification in Unicode article by Otfried Cheong  uses the following two characters as an example to illustrate what kinds of characters have been unified, even though this particular pair has not been unified:
footnote: In Fact, the radical on the left is simplified form. Simplified Chinese Character are not always simpler than other variants，it’s more of a unified standard form! Anyway, there are indeed a lot of variants which cause communication difficulty in some extend in Chinese world. – A reader from Beijing
For some users, this unification was not acceptable, however. Otfried Cheong says:
Mokurai 黙雷 Cherlin says:
Maybe worth noting that Windows, Mac, and Linux all have character selection tools designed to make cut/paste with special characters a little easier (e.g., linux utilities include gucharmap and kcharselect)?
If you have trouble pasting from other applications: Emacs by default requests a selection of type COMPOUND_TEXT. It seems that xterm (and other applications) ignore this sometimes and reply using UTF-8 encoded text.
Here’s how to tell Emacs to request UTF-8 first:
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))
It seems Emacs does not support some combining characters. For instance if you paste or read from a file the word страни́ца (as seen in Wiktionary) you will see страни´ца. – DanielClemente, Apr2012, 220.127.116.11 in X.org in Debian