Mercurial > emacs
annotate doc/emacs/mule.texi @ 103450:79a0347eb272
(Charsets): Update the description for the new charset.
(list-character-sets): New findex.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 17 Jun 2009 01:14:36 +0000 |
parents | 304eb5ff2a17 |
children | 2e5fc429d232 |
rev | line source |
---|---|
84260 | 1 @c This is part of the Emacs manual. |
2 @c Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004, | |
100974 | 3 @c 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
84260 | 4 @c See file emacs.texi for copying conditions. |
5 @node International, Major Modes, Frames, Top | |
6 @chapter International Character Set Support | |
93759 | 7 @c This node is referenced in the tutorial. When renaming or deleting |
8 @c it, the tutorial needs to be adjusted. (TUTORIAL.de) | |
84260 | 9 @cindex MULE |
10 @cindex international scripts | |
11 @cindex multibyte characters | |
12 @cindex encoding of characters | |
13 | |
14 @cindex Celtic | |
15 @cindex Chinese | |
16 @cindex Cyrillic | |
17 @cindex Czech | |
18 @cindex Devanagari | |
19 @cindex Hindi | |
20 @cindex Marathi | |
21 @cindex Ethiopic | |
22 @cindex German | |
23 @cindex Greek | |
24 @cindex Hebrew | |
25 @cindex IPA | |
26 @cindex Japanese | |
27 @cindex Korean | |
28 @cindex Lao | |
29 @cindex Latin | |
30 @cindex Polish | |
31 @cindex Romanian | |
32 @cindex Slovak | |
33 @cindex Slovenian | |
34 @cindex Thai | |
35 @cindex Tibetan | |
36 @cindex Turkish | |
37 @cindex Vietnamese | |
38 @cindex Dutch | |
39 @cindex Spanish | |
40 Emacs supports a wide variety of international character sets, | |
41 including European and Vietnamese variants of the Latin alphabet, as | |
42 well as Cyrillic, Devanagari (for Hindi and Marathi), Ethiopic, Greek, | |
43 Han (for Chinese and Japanese), Hangul (for Korean), Hebrew, IPA, | |
44 Kannada, Lao, Malayalam, Tamil, Thai, Tibetan, and Vietnamese scripts. | |
45 Emacs also supports various encodings of these characters used by | |
46 other internationalized software, such as word processors and mailers. | |
47 | |
48 Emacs allows editing text with international characters by supporting | |
49 all the related activities: | |
50 | |
51 @itemize @bullet | |
52 @item | |
53 You can visit files with non-@acronym{ASCII} characters, save non-@acronym{ASCII} text, and | |
54 pass non-@acronym{ASCII} text between Emacs and programs it invokes (such as | |
55 compilers, spell-checkers, and mailers). Setting your language | |
56 environment (@pxref{Language Environments}) takes care of setting up the | |
57 coding systems and other options for a specific language or culture. | |
58 Alternatively, you can specify how Emacs should encode or decode text | |
59 for each command; see @ref{Text Coding}. | |
60 | |
61 @item | |
62 You can display non-@acronym{ASCII} characters encoded by the various | |
63 scripts. This works by using appropriate fonts on graphics displays | |
64 (@pxref{Defining Fontsets}), and by sending special codes to text-only | |
65 displays (@pxref{Terminal Coding}). If some characters are displayed | |
66 incorrectly, refer to @ref{Undisplayable Characters}, which describes | |
67 possible problems and explains how to solve them. | |
68 | |
69 @item | |
70 You can insert non-@acronym{ASCII} characters or search for them. To do that, | |
71 you can specify an input method (@pxref{Select Input Method}) suitable | |
72 for your language, or use the default input method set up when you set | |
73 your language environment. If | |
74 your keyboard can produce non-@acronym{ASCII} characters, you can select an | |
75 appropriate keyboard coding system (@pxref{Terminal Coding}), and Emacs | |
76 will accept those characters. Latin-1 characters can also be input by | |
77 using the @kbd{C-x 8} prefix, see @ref{Unibyte Mode}. | |
78 | |
79 On X Window systems, your locale should be set to an appropriate value | |
80 to make sure Emacs interprets keyboard input correctly; see | |
81 @ref{Language Environments, locales}. | |
82 @end itemize | |
83 | |
84 The rest of this chapter describes these issues in detail. | |
85 | |
86 @menu | |
87 * International Chars:: Basic concepts of multibyte characters. | |
88 * Enabling Multibyte:: Controlling whether to use multibyte characters. | |
89 * Language Environments:: Setting things up for the language you use. | |
90 * Input Methods:: Entering text characters not on your keyboard. | |
91 * Select Input Method:: Specifying your choice of input methods. | |
92 * Coding Systems:: Character set conversion when you read and | |
93 write files, and so on. | |
94 * Recognize Coding:: How Emacs figures out which conversion to use. | |
95 * Specify Coding:: Specifying a file's coding system explicitly. | |
96 * Output Coding:: Choosing coding systems for output. | |
97 * Text Coding:: Choosing conversion to use for file text. | |
98 * Communication Coding:: Coding systems for interprocess communication. | |
99 * File Name Coding:: Coding systems for file @emph{names}. | |
100 * Terminal Coding:: Specifying coding systems for converting | |
101 terminal input and output. | |
102 * Fontsets:: Fontsets are collections of fonts | |
103 that cover the whole spectrum of characters. | |
104 * Defining Fontsets:: Defining a new fontset. | |
102245
ea664a60c2ec
(International): Link to Modifying Fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
102244
diff
changeset
|
105 * Modifying Fontsets:: Modifying an existing fontset. |
84260 | 106 * Undisplayable Characters:: When characters don't display. |
107 * Unibyte Mode:: You can pick one European character set | |
108 to use without multibyte characters. | |
109 * Charsets:: How Emacs groups its internal character codes. | |
110 @end menu | |
111 | |
112 @node International Chars | |
113 @section Introduction to International Character Sets | |
114 | |
115 The users of international character sets and scripts have | |
116 established many more-or-less standard coding systems for storing | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
117 files. These coding systems are typically @dfn{multibyte}, meaning |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
118 that sequences of two or more bytes are used to represent individual |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
119 non-@acronym{ASCII} characters. |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
120 |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
121 @cindex Unicode |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
122 Internally, Emacs uses its own multibyte character encoding, which |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
123 is a superset of the @dfn{Unicode} standard. This internal encoding |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
124 allows characters from almost every known script to be intermixed in a |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
125 single buffer or string. Emacs translates between the multibyte |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
126 character encoding and various other coding systems when reading and |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
127 writing files, and when exchanging data with subprocesses. |
84260 | 128 |
129 @kindex C-h h | |
130 @findex view-hello-file | |
131 @cindex undisplayable characters | |
132 @cindex @samp{?} in display | |
133 The command @kbd{C-h h} (@code{view-hello-file}) displays the file | |
134 @file{etc/HELLO}, which shows how to say ``hello'' in many languages. | |
135 This illustrates various scripts. If some characters can't be | |
136 displayed on your terminal, they appear as @samp{?} or as hollow boxes | |
137 (@pxref{Undisplayable Characters}). | |
138 | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
139 Keyboards, even in the countries where these character sets are |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
140 used, generally don't have keys for all the characters in them. You |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
141 can insert characters that your keyboard does not support, using |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
142 @kbd{C-q} (@code{quoted-insert}) or @kbd{C-x 8 @key{RET}} |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
143 (@code{ucs-insert}). @xref{Inserting Text}. Emacs also supports |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
144 various @dfn{input methods}, typically one for each script or |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
145 language, which make it easier to type characters in the script. |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
146 @xref{Input Methods}. |
84260 | 147 |
148 @kindex C-x RET | |
149 The prefix key @kbd{C-x @key{RET}} is used for commands that pertain | |
150 to multibyte characters, coding systems, and input methods. | |
151 | |
97173
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
152 @kindex C-x = |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
153 @findex what-cursor-position |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
154 The command @kbd{C-x =} (@code{what-cursor-position}) shows |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
155 information about the character at point. In addition to the |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
156 character position, which was described in @ref{Position Info}, this |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
157 command displays how the character is encoded. For instance, it |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
158 displays the following line in the echo area for the character |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
159 @samp{c}: |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
160 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
161 @smallexample |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
162 Char: c (99, #o143, #x63) point=28062 of 36168 (78%) column=53 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
163 @end smallexample |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
164 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
165 The four values after @samp{Char:} describe the character that |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
166 follows point, first by showing it and then by giving its character |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
167 code in decimal, octal and hex. For a non-@acronym{ASCII} multibyte |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
168 character, these are followed by @samp{file} and the character's |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
169 representation, in hex, in the buffer's coding system, if that coding |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
170 system encodes the character safely and with a single byte |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
171 (@pxref{Coding Systems}). If the character's encoding is longer than |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
172 one byte, Emacs shows @samp{file ...}. |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
173 |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
174 As a special case, if the character lies in the range 128 (0200 |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
175 octal) through 159 (0237 octal), it stands for a ``raw'' byte that |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
176 does not correspond to any specific displayable character. Such a |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
177 ``character'' lies within the @code{eight-bit-control} character set, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
178 and is displayed as an escaped octal character code. In this case, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
179 @kbd{C-x =} shows @samp{part of display ...} instead of @samp{file}. |
97173
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
180 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
181 @cindex character set of character at point |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
182 @cindex font of character at point |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
183 @cindex text properties at point |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
184 @cindex face at point |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
185 With a prefix argument (@kbd{C-u C-x =}), this command displays a |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
186 detailed description of the character in a window: |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
187 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
188 @itemize @bullet |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
189 @item |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
190 The character set name, and the codes that identify the character |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
191 within that character set; @acronym{ASCII} characters are identified |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
192 as belonging to the @code{ascii} character set. |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
193 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
194 @item |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
195 The character's syntax and categories. |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
196 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
197 @item |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
198 The character's encodings, both internally in the buffer, and externally |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
199 if you were to save the file. |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
200 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
201 @item |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
202 What keys to type to input the character in the current input method |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
203 (if it supports the character). |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
204 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
205 @item |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
206 If you are running Emacs on a graphical display, the font name and |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
207 glyph code for the character. If you are running Emacs on a text-only |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
208 terminal, the code(s) sent to the terminal. |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
209 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
210 @item |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
211 The character's text properties (@pxref{Text Properties,,, |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
212 elisp, the Emacs Lisp Reference Manual}), including any non-default |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
213 faces used to display the character, and any overlays containing it |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
214 (@pxref{Overlays,,, elisp, the same manual}). |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
215 @end itemize |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
216 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
217 Here's an example showing the Latin-1 character A with grave accent, |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
218 in a buffer whose coding system is @code{utf-8-unix}: |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
219 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
220 @smallexample |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
221 character: @`A (192, #o300, #xc0) |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
222 preferred charset: unicode (Unicode (ISO10646)) |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
223 code point: 0xC0 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
224 syntax: w which means: word |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
225 category: j:Japanese l:Latin v:Vietnamese |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
226 buffer code: #xC3 #x80 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
227 file code: not encodable by coding system undecided-unix |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
228 display: by this font (glyph code) |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
229 xft:-unknown-DejaVu Sans Mono-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1 (#x82) |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
230 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
231 Character code properties: customize what to show |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
232 name: LATIN CAPITAL LETTER A WITH GRAVE |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
233 general-category: Lu (Letter, Uppercase) |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
234 decomposition: (65 768) ('A' 'Ì€') |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
235 old-name: LATIN CAPITAL LETTER A GRAVE |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
236 |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
237 There are text properties here: |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
238 auto-composed t |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
239 @end smallexample |
38abfd74e4d2
(International Chars): Describe C-x =.
Chong Yidong <cyd@stupidchicken.com>
parents:
93759
diff
changeset
|
240 |
84260 | 241 @node Enabling Multibyte |
242 @section Enabling Multibyte Characters | |
243 | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
244 By default, Emacs starts in multibyte mode: it stores the contents |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
245 of buffers and strings using an internal encoding that represents |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
246 non-@acronym{ASCII} characters using multi-byte sequences. Multibyte |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
247 mode allows you to use all the supported languages and scripts without |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
248 limitations. |
84260 | 249 |
250 @cindex turn multibyte support on or off | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
251 Under very special circumstances, you may want to disable multibyte |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
252 character support, either for Emacs as a whole, or for a single |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
253 buffer. When multibyte characters are disabled in a buffer, we call |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
254 that @dfn{unibyte mode}. In unibyte mode, each character in the |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
255 buffer has a character code ranging from 0 through 255 (0377 octal); 0 |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
256 through 127 (0177 octal) represent @acronym{ASCII} characters, and 128 |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
257 (0200 octal) through 255 (0377 octal) represent non-@acronym{ASCII} |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
258 characters. |
84260 | 259 |
260 To edit a particular file in unibyte representation, visit it using | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
261 @code{find-file-literally}. @xref{Visiting}. You can convert a |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
262 multibyte buffer to unibyte by saving it to a file, killing the |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
263 buffer, and visiting the file again with @code{find-file-literally}. |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
264 Alternatively, you can use @kbd{C-x @key{RET} c} |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
265 (@code{universal-coding-system-argument}) and specify @samp{raw-text} |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
266 as the coding system with which to visit or save a file. @xref{Text |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
267 Coding}. Unlike @code{find-file-literally}, finding a file as |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
268 @samp{raw-text} doesn't disable format conversion, uncompression, or |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
269 auto mode selection. |
84260 | 270 |
271 @vindex enable-multibyte-characters | |
272 @vindex default-enable-multibyte-characters | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
273 @cindex environment variables, and non-@acronym{ASCII} characters |
84260 | 274 To turn off multibyte character support by default, start Emacs with |
275 the @samp{--unibyte} option (@pxref{Initial Options}), or set the | |
276 environment variable @env{EMACS_UNIBYTE}. You can also customize | |
277 @code{enable-multibyte-characters} or, equivalently, directly set the | |
278 variable @code{default-enable-multibyte-characters} to @code{nil} in | |
279 your init file to have basically the same effect as @samp{--unibyte}. | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
280 With @samp{--unibyte}, multibyte strings are not created during |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
281 initialization from the values of environment variables, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
282 @file{/etc/passwd} entries etc., even if those contain |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
283 non-@acronym{ASCII} characters. |
84260 | 284 |
285 @cindex Lisp files, and multibyte operation | |
286 @cindex multibyte operation, and Lisp files | |
287 @cindex unibyte operation, and Lisp files | |
288 @cindex init file, and non-@acronym{ASCII} characters | |
289 Emacs normally loads Lisp files as multibyte, regardless of whether | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
290 you used @samp{--unibyte}. This includes the Emacs initialization |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
291 file, @file{.emacs}, and the initialization files of Emacs packages |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
292 such as Gnus. However, you can specify unibyte loading for a |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
293 particular Lisp file, by putting @w{@samp{-*-unibyte: t;-*-}} in a |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
294 comment on the first line (@pxref{File Variables}). Then that file is |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
295 always loaded as unibyte text. The motivation for these conventions |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
296 is that it is more reliable to always load any particular Lisp file in |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
297 the same way. However, you can load a Lisp file as unibyte, on any |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
298 one occasion, by typing @kbd{C-x @key{RET} c raw-text @key{RET}} |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
299 immediately before loading it. |
84260 | 300 |
301 The mode line indicates whether multibyte character support is | |
302 enabled in the current buffer. If it is, there are two or more | |
303 characters (most often two dashes) near the beginning of the mode | |
304 line, before the indication of the visited file's end-of-line | |
305 convention (colon, backslash, etc.). When multibyte characters | |
306 are not enabled, nothing precedes the colon except a single dash. | |
307 @xref{Mode Line}, for more details about this. | |
308 | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
309 @findex toggle-enable-multibyte-characters |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
310 To convert a unibyte session to a multibyte session, set |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
311 @code{default-enable-multibyte-characters} to @code{t}. Buffers which |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
312 were created in the unibyte session before you turn on multibyte |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
313 support will stay unibyte. You can turn on multibyte support in a |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
314 specific buffer by invoking the command |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
315 @code{toggle-enable-multibyte-characters} in that buffer. |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
316 |
84260 | 317 @node Language Environments |
318 @section Language Environments | |
319 @cindex language environments | |
320 | |
321 All supported character sets are supported in Emacs buffers whenever | |
322 multibyte characters are enabled; there is no need to select a | |
323 particular language in order to display its characters in an Emacs | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
324 buffer. However, it is important to select a @dfn{language |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
325 environment} in order to set various defaults. Roughly speaking, the |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
326 language environment represents a choice of preferred script rather |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
327 than a choice of language. |
84260 | 328 |
329 The language environment controls which coding systems to recognize | |
330 when reading text (@pxref{Recognize Coding}). This applies to files, | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
331 incoming mail, and any other text you read into Emacs. It may also |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
332 specify the default coding system to use when you create a file. Each |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
333 language environment also specifies a default input method. |
84260 | 334 |
335 @findex set-language-environment | |
336 @vindex current-language-environment | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
337 To select a language environment, customize the variable |
84260 | 338 @code{current-language-environment} or use the command @kbd{M-x |
339 set-language-environment}. It makes no difference which buffer is | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
340 current when you use this command, because the effects apply globally |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
341 to the Emacs session. The supported language environments include: |
84260 | 342 |
343 @cindex Euro sign | |
344 @cindex UTF-8 | |
345 @quotation | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
346 ASCII, Belarusian, Bengali, Brazilian Portuguese, Bulgarian, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
347 Chinese-BIG5, Chinese-CNS, Chinese-EUC-TW, Chinese-GB, Chinese-GBK, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
348 Chinese-GB18030, Croatian, Cyrillic-ALT, Cyrillic-ISO, Cyrillic-KOI8, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
349 Czech, Devanagari, Dutch, English, Esperanto, Ethiopic, French, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
350 Georgian, German, Greek, Gujarati, Hebrew, IPA, Italian, Japanese, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
351 Kannada, Khmer, Korean, Lao, Latin-1, Latin-2, Latin-3, Latin-4, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
352 Latin-5, Latin-6, Latin-7, Latin-8 (Celtic), Latin-9 (updated Latin-1 |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
353 with the Euro sign), Latvian, Lithuanian, Malayalam, Oriya, Polish, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
354 Punjabi, Romanian, Russian, Sinhala, Slovak, Slovenian, Spanish, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
355 Swedish, TaiViet, Tajik, Tamil, Telugu, Thai, Tibetan, Turkish, UTF-8 |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
356 (for a setup which prefers Unicode characters and files encoded in |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
357 UTF-8), Ukrainian, Vietnamese, Welsh, and Windows-1255 (for a setup |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
358 which prefers Cyrillic characters and files encoded in Windows-1255). |
84260 | 359 @end quotation |
360 | |
361 @cindex fonts for various scripts | |
362 @cindex Intlfonts package, installation | |
363 To display the script(s) used by your language environment on a | |
364 graphical display, you need to have a suitable font. If some of the | |
365 characters appear as empty boxes, you should install the GNU Intlfonts | |
366 package, which includes fonts for most supported scripts.@footnote{If | |
367 you run Emacs on X, you need to inform the X server about the location | |
368 of the newly installed fonts with the following commands: | |
369 | |
370 @example | |
371 xset fp+ /usr/local/share/emacs/fonts | |
372 xset fp rehash | |
373 @end example | |
374 } | |
375 @xref{Fontsets}, for more details about setting up your fonts. | |
376 | |
377 @findex set-locale-environment | |
378 @vindex locale-language-names | |
379 @vindex locale-charset-language-names | |
380 @cindex locales | |
381 Some operating systems let you specify the character-set locale you | |
382 are using by setting the locale environment variables @env{LC_ALL}, | |
383 @env{LC_CTYPE}, or @env{LANG}.@footnote{If more than one of these is | |
384 set, the first one that is nonempty specifies your locale for this | |
385 purpose.} During startup, Emacs looks up your character-set locale's | |
386 name in the system locale alias table, matches its canonical name | |
387 against entries in the value of the variables | |
388 @code{locale-charset-language-names} and @code{locale-language-names}, | |
389 and selects the corresponding language environment if a match is found. | |
390 (The former variable overrides the latter.) It also adjusts the display | |
391 table and terminal coding system, the locale coding system, the | |
392 preferred coding system as needed for the locale, and---last but not | |
393 least---the way Emacs decodes non-@acronym{ASCII} characters sent by your keyboard. | |
394 | |
395 If you modify the @env{LC_ALL}, @env{LC_CTYPE}, or @env{LANG} | |
396 environment variables while running Emacs, you may want to invoke the | |
397 @code{set-locale-environment} function afterwards to readjust the | |
398 language environment from the new locale. | |
399 | |
400 @vindex locale-preferred-coding-systems | |
401 The @code{set-locale-environment} function normally uses the preferred | |
402 coding system established by the language environment to decode system | |
403 messages. But if your locale matches an entry in the variable | |
404 @code{locale-preferred-coding-systems}, Emacs uses the corresponding | |
405 coding system instead. For example, if the locale @samp{ja_JP.PCK} | |
406 matches @code{japanese-shift-jis} in | |
407 @code{locale-preferred-coding-systems}, Emacs uses that encoding even | |
408 though it might normally use @code{japanese-iso-8bit}. | |
409 | |
410 You can override the language environment chosen at startup with | |
411 explicit use of the command @code{set-language-environment}, or with | |
412 customization of @code{current-language-environment} in your init | |
413 file. | |
414 | |
415 @kindex C-h L | |
416 @findex describe-language-environment | |
417 To display information about the effects of a certain language | |
418 environment @var{lang-env}, use the command @kbd{C-h L @var{lang-env} | |
419 @key{RET}} (@code{describe-language-environment}). This tells you | |
420 which languages this language environment is useful for, and lists the | |
421 character sets, coding systems, and input methods that go with it. It | |
422 also shows some sample text to illustrate scripts used in this | |
423 language environment. If you give an empty input for @var{lang-env}, | |
424 this command describes the chosen language environment. | |
425 | |
426 @vindex set-language-environment-hook | |
427 You can customize any language environment with the normal hook | |
428 @code{set-language-environment-hook}. The command | |
429 @code{set-language-environment} runs that hook after setting up the new | |
430 language environment. The hook functions can test for a specific | |
431 language environment by checking the variable | |
432 @code{current-language-environment}. This hook is where you should | |
433 put non-default settings for specific language environment, such as | |
434 coding systems for keyboard input and terminal output, the default | |
435 input method, etc. | |
436 | |
437 @vindex exit-language-environment-hook | |
438 Before it starts to set up the new language environment, | |
439 @code{set-language-environment} first runs the hook | |
440 @code{exit-language-environment-hook}. This hook is useful for undoing | |
441 customizations that were made with @code{set-language-environment-hook}. | |
442 For instance, if you set up a special key binding in a specific language | |
443 environment using @code{set-language-environment-hook}, you should set | |
444 up @code{exit-language-environment-hook} to restore the normal binding | |
445 for that key. | |
446 | |
447 @node Input Methods | |
448 @section Input Methods | |
449 | |
450 @cindex input methods | |
451 An @dfn{input method} is a kind of character conversion designed | |
452 specifically for interactive input. In Emacs, typically each language | |
453 has its own input method; sometimes several languages which use the same | |
454 characters can share one input method. A few languages support several | |
455 input methods. | |
456 | |
457 The simplest kind of input method works by mapping @acronym{ASCII} letters | |
458 into another alphabet; this allows you to use one other alphabet | |
459 instead of @acronym{ASCII}. The Greek and Russian input methods | |
460 work this way. | |
461 | |
462 A more powerful technique is composition: converting sequences of | |
463 characters into one letter. Many European input methods use composition | |
464 to produce a single non-@acronym{ASCII} letter from a sequence that consists of a | |
465 letter followed by accent characters (or vice versa). For example, some | |
466 methods convert the sequence @kbd{a'} into a single accented letter. | |
467 These input methods have no special commands of their own; all they do | |
468 is compose sequences of printing characters. | |
469 | |
470 The input methods for syllabic scripts typically use mapping followed | |
471 by composition. The input methods for Thai and Korean work this way. | |
472 First, letters are mapped into symbols for particular sounds or tone | |
473 marks; then, sequences of these which make up a whole syllable are | |
474 mapped into one syllable sign. | |
475 | |
476 Chinese and Japanese require more complex methods. In Chinese input | |
477 methods, first you enter the phonetic spelling of a Chinese word (in | |
478 input method @code{chinese-py}, among others), or a sequence of | |
479 portions of the character (input methods @code{chinese-4corner} and | |
480 @code{chinese-sw}, and others). One input sequence typically | |
481 corresponds to many possible Chinese characters. You select the one | |
482 you mean using keys such as @kbd{C-f}, @kbd{C-b}, @kbd{C-n}, | |
483 @kbd{C-p}, and digits, which have special meanings in this situation. | |
484 | |
485 The possible characters are conceptually arranged in several rows, | |
486 with each row holding up to 10 alternatives. Normally, Emacs displays | |
487 just one row at a time, in the echo area; @code{(@var{i}/@var{j})} | |
488 appears at the beginning, to indicate that this is the @var{i}th row | |
489 out of a total of @var{j} rows. Type @kbd{C-n} or @kbd{C-p} to | |
490 display the next row or the previous row. | |
491 | |
492 Type @kbd{C-f} and @kbd{C-b} to move forward and backward among | |
493 the alternatives in the current row. As you do this, Emacs highlights | |
494 the current alternative with a special color; type @code{C-@key{SPC}} | |
495 to select the current alternative and use it as input. The | |
496 alternatives in the row are also numbered; the number appears before | |
497 the alternative. Typing a digit @var{n} selects the @var{n}th | |
498 alternative of the current row and uses it as input. | |
499 | |
500 @key{TAB} in these Chinese input methods displays a buffer showing | |
501 all the possible characters at once; then clicking @kbd{Mouse-2} on | |
502 one of them selects that alternative. The keys @kbd{C-f}, @kbd{C-b}, | |
503 @kbd{C-n}, @kbd{C-p}, and digits continue to work as usual, but they | |
504 do the highlighting in the buffer showing the possible characters, | |
505 rather than in the echo area. | |
506 | |
507 In Japanese input methods, first you input a whole word using | |
508 phonetic spelling; then, after the word is in the buffer, Emacs | |
509 converts it into one or more characters using a large dictionary. One | |
510 phonetic spelling corresponds to a number of different Japanese words; | |
511 to select one of them, use @kbd{C-n} and @kbd{C-p} to cycle through | |
512 the alternatives. | |
513 | |
514 Sometimes it is useful to cut off input method processing so that the | |
515 characters you have just entered will not combine with subsequent | |
516 characters. For example, in input method @code{latin-1-postfix}, the | |
517 sequence @kbd{e '} combines to form an @samp{e} with an accent. What if | |
518 you want to enter them as separate characters? | |
519 | |
520 One way is to type the accent twice; this is a special feature for | |
521 entering the separate letter and accent. For example, @kbd{e ' '} gives | |
522 you the two characters @samp{e'}. Another way is to type another letter | |
523 after the @kbd{e}---something that won't combine with that---and | |
524 immediately delete it. For example, you could type @kbd{e e @key{DEL} | |
525 '} to get separate @samp{e} and @samp{'}. | |
526 | |
527 Another method, more general but not quite as easy to type, is to use | |
528 @kbd{C-\ C-\} between two characters to stop them from combining. This | |
529 is the command @kbd{C-\} (@code{toggle-input-method}) used twice. | |
530 @ifnottex | |
531 @xref{Select Input Method}. | |
532 @end ifnottex | |
533 | |
534 @cindex incremental search, input method interference | |
535 @kbd{C-\ C-\} is especially useful inside an incremental search, | |
536 because it stops waiting for more characters to combine, and starts | |
537 searching for what you have already entered. | |
538 | |
539 To find out how to input the character after point using the current | |
540 input method, type @kbd{C-u C-x =}. @xref{Position Info}. | |
541 | |
542 @vindex input-method-verbose-flag | |
543 @vindex input-method-highlight-flag | |
544 The variables @code{input-method-highlight-flag} and | |
545 @code{input-method-verbose-flag} control how input methods explain | |
546 what is happening. If @code{input-method-highlight-flag} is | |
547 non-@code{nil}, the partial sequence is highlighted in the buffer (for | |
548 most input methods---some disable this feature). If | |
549 @code{input-method-verbose-flag} is non-@code{nil}, the list of | |
550 possible characters to type next is displayed in the echo area (but | |
551 not when you are in the minibuffer). | |
552 | |
553 @node Select Input Method | |
554 @section Selecting an Input Method | |
555 | |
556 @table @kbd | |
557 @item C-\ | |
558 Enable or disable use of the selected input method. | |
559 | |
560 @item C-x @key{RET} C-\ @var{method} @key{RET} | |
561 Select a new input method for the current buffer. | |
562 | |
563 @item C-h I @var{method} @key{RET} | |
564 @itemx C-h C-\ @var{method} @key{RET} | |
565 @findex describe-input-method | |
566 @kindex C-h I | |
567 @kindex C-h C-\ | |
568 Describe the input method @var{method} (@code{describe-input-method}). | |
569 By default, it describes the current input method (if any). This | |
570 description should give you the full details of how to use any | |
571 particular input method. | |
572 | |
573 @item M-x list-input-methods | |
574 Display a list of all the supported input methods. | |
575 @end table | |
576 | |
577 @findex set-input-method | |
578 @vindex current-input-method | |
579 @kindex C-x RET C-\ | |
580 To choose an input method for the current buffer, use @kbd{C-x | |
581 @key{RET} C-\} (@code{set-input-method}). This command reads the | |
582 input method name from the minibuffer; the name normally starts with the | |
583 language environment that it is meant to be used with. The variable | |
584 @code{current-input-method} records which input method is selected. | |
585 | |
586 @findex toggle-input-method | |
587 @kindex C-\ | |
588 Input methods use various sequences of @acronym{ASCII} characters to | |
589 stand for non-@acronym{ASCII} characters. Sometimes it is useful to | |
590 turn off the input method temporarily. To do this, type @kbd{C-\} | |
591 (@code{toggle-input-method}). To reenable the input method, type | |
592 @kbd{C-\} again. | |
593 | |
594 If you type @kbd{C-\} and you have not yet selected an input method, | |
595 it prompts for you to specify one. This has the same effect as using | |
596 @kbd{C-x @key{RET} C-\} to specify an input method. | |
597 | |
598 When invoked with a numeric argument, as in @kbd{C-u C-\}, | |
599 @code{toggle-input-method} always prompts you for an input method, | |
600 suggesting the most recently selected one as the default. | |
601 | |
602 @vindex default-input-method | |
603 Selecting a language environment specifies a default input method for | |
604 use in various buffers. When you have a default input method, you can | |
605 select it in the current buffer by typing @kbd{C-\}. The variable | |
606 @code{default-input-method} specifies the default input method | |
607 (@code{nil} means there is none). | |
608 | |
609 In some language environments, which support several different input | |
610 methods, you might want to use an input method different from the | |
611 default chosen by @code{set-language-environment}. You can instruct | |
612 Emacs to select a different default input method for a certain | |
613 language environment, if you wish, by using | |
614 @code{set-language-environment-hook} (@pxref{Language Environments, | |
615 set-language-environment-hook}). For example: | |
616 | |
617 @lisp | |
618 (defun my-chinese-setup () | |
619 "Set up my private Chinese environment." | |
620 (if (equal current-language-environment "Chinese-GB") | |
621 (setq default-input-method "chinese-tonepy"))) | |
622 (add-hook 'set-language-environment-hook 'my-chinese-setup) | |
623 @end lisp | |
624 | |
625 @noindent | |
626 This sets the default input method to be @code{chinese-tonepy} | |
627 whenever you choose a Chinese-GB language environment. | |
628 | |
85934
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
629 You can instruct Emacs to activate a certain input method |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
630 automatically. For example: |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
631 |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
632 @lisp |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
633 (add-hook 'text-mode-hook |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
634 (lambda () (set-input-method "german-prefix"))) |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
635 @end lisp |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
636 |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
637 @noindent |
103235
304eb5ff2a17
* mule.texi (Select Input Method): Fix typo.
Chong Yidong <cyd@stupidchicken.com>
parents:
103164
diff
changeset
|
638 This activates the input method ``german-prefix'' automatically in the |
85934
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
639 Text mode. |
0c8b86e9b028
(Select Input Method): Describe how to activate an input
Kenichi Handa <handa@m17n.org>
parents:
84260
diff
changeset
|
640 |
84260 | 641 @findex quail-set-keyboard-layout |
642 Some input methods for alphabetic scripts work by (in effect) | |
643 remapping the keyboard to emulate various keyboard layouts commonly used | |
644 for those scripts. How to do this remapping properly depends on your | |
645 actual keyboard layout. To specify which layout your keyboard has, use | |
646 the command @kbd{M-x quail-set-keyboard-layout}. | |
647 | |
648 @findex quail-show-key | |
649 You can use the command @kbd{M-x quail-show-key} to show what key (or | |
650 key sequence) to type in order to input the character following point, | |
651 using the selected keyboard layout. The command @kbd{C-u C-x =} also | |
652 shows that information in addition to the other information about the | |
653 character. | |
654 | |
655 @findex list-input-methods | |
656 To see a list of all the supported input methods, type @kbd{M-x | |
657 list-input-methods}. The list gives information about each input | |
658 method, including the string that stands for it in the mode line. | |
659 | |
660 @node Coding Systems | |
661 @section Coding Systems | |
662 @cindex coding systems | |
663 | |
664 Users of various languages have established many more-or-less standard | |
665 coding systems for representing them. Emacs does not use these coding | |
666 systems internally; instead, it converts from various coding systems to | |
667 its own system when reading data, and converts the internal coding | |
668 system to other coding systems when writing data. Conversion is | |
669 possible in reading or writing files, in sending or receiving from the | |
670 terminal, and in exchanging data with subprocesses. | |
671 | |
672 Emacs assigns a name to each coding system. Most coding systems are | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
673 used for one language, and the name of the coding system starts with |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
674 the language name. Some coding systems are used for several |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
675 languages; their names usually start with @samp{iso}. There are also |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
676 special coding systems, such as @code{no-conversion}, @code{raw-text}, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
677 and @code{emacs-internal}. |
84260 | 678 |
679 @cindex international files from DOS/Windows systems | |
680 A special class of coding systems, collectively known as | |
681 @dfn{codepages}, is designed to support text encoded by MS-Windows and | |
682 MS-DOS software. The names of these coding systems are | |
683 @code{cp@var{nnnn}}, where @var{nnnn} is a 3- or 4-digit number of the | |
684 codepage. You can use these encodings just like any other coding | |
685 system; for example, to visit a file encoded in codepage 850, type | |
686 @kbd{C-x @key{RET} c cp850 @key{RET} C-x C-f @var{filename} | |
98431
1d8ecf7d1560
(Coding Systems): Don't mention codepage-setup.
Eli Zaretskii <eliz@gnu.org>
parents:
97173
diff
changeset
|
687 @key{RET}}. |
84260 | 688 |
689 In addition to converting various representations of non-@acronym{ASCII} | |
690 characters, a coding system can perform end-of-line conversion. Emacs | |
691 handles three different conventions for how to separate lines in a file: | |
692 newline, carriage-return linefeed, and just carriage-return. | |
693 | |
694 @table @kbd | |
695 @item C-h C @var{coding} @key{RET} | |
696 Describe coding system @var{coding}. | |
697 | |
698 @item C-h C @key{RET} | |
699 Describe the coding systems currently in use. | |
700 | |
701 @item M-x list-coding-systems | |
702 Display a list of all the supported coding systems. | |
703 @end table | |
704 | |
705 @kindex C-h C | |
706 @findex describe-coding-system | |
707 The command @kbd{C-h C} (@code{describe-coding-system}) displays | |
708 information about particular coding systems, including the end-of-line | |
709 conversion specified by those coding systems. You can specify a coding | |
710 system name as the argument; alternatively, with an empty argument, it | |
711 describes the coding systems currently selected for various purposes, | |
712 both in the current buffer and as the defaults, and the priority list | |
713 for recognizing coding systems (@pxref{Recognize Coding}). | |
714 | |
715 @findex list-coding-systems | |
716 To display a list of all the supported coding systems, type @kbd{M-x | |
717 list-coding-systems}. The list gives information about each coding | |
718 system, including the letter that stands for it in the mode line | |
719 (@pxref{Mode Line}). | |
720 | |
721 @cindex end-of-line conversion | |
722 @cindex line endings | |
723 @cindex MS-DOS end-of-line conversion | |
724 @cindex Macintosh end-of-line conversion | |
725 Each of the coding systems that appear in this list---except for | |
726 @code{no-conversion}, which means no conversion of any kind---specifies | |
727 how and whether to convert printing characters, but leaves the choice of | |
728 end-of-line conversion to be decided based on the contents of each file. | |
729 For example, if the file appears to use the sequence carriage-return | |
730 linefeed to separate lines, DOS end-of-line conversion will be used. | |
731 | |
732 Each of the listed coding systems has three variants which specify | |
733 exactly what to do for end-of-line conversion: | |
734 | |
735 @table @code | |
736 @item @dots{}-unix | |
737 Don't do any end-of-line conversion; assume the file uses | |
738 newline to separate lines. (This is the convention normally used | |
739 on Unix and GNU systems.) | |
740 | |
741 @item @dots{}-dos | |
742 Assume the file uses carriage-return linefeed to separate lines, and do | |
743 the appropriate conversion. (This is the convention normally used on | |
744 Microsoft systems.@footnote{It is also specified for MIME @samp{text/*} | |
745 bodies and in other network transport contexts. It is different | |
746 from the SGML reference syntax record-start/record-end format which | |
747 Emacs doesn't support directly.}) | |
748 | |
749 @item @dots{}-mac | |
750 Assume the file uses carriage-return to separate lines, and do the | |
751 appropriate conversion. (This is the convention normally used on the | |
752 Macintosh system.) | |
753 @end table | |
754 | |
755 These variant coding systems are omitted from the | |
756 @code{list-coding-systems} display for brevity, since they are entirely | |
757 predictable. For example, the coding system @code{iso-latin-1} has | |
758 variants @code{iso-latin-1-unix}, @code{iso-latin-1-dos} and | |
759 @code{iso-latin-1-mac}. | |
760 | |
761 @cindex @code{undecided}, coding system | |
762 The coding systems @code{unix}, @code{dos}, and @code{mac} are | |
763 aliases for @code{undecided-unix}, @code{undecided-dos}, and | |
764 @code{undecided-mac}, respectively. These coding systems specify only | |
765 the end-of-line conversion, and leave the character code conversion to | |
766 be deduced from the text itself. | |
767 | |
768 The coding system @code{raw-text} is good for a file which is mainly | |
769 @acronym{ASCII} text, but may contain byte values above 127 which are | |
770 not meant to encode non-@acronym{ASCII} characters. With | |
771 @code{raw-text}, Emacs copies those byte values unchanged, and sets | |
772 @code{enable-multibyte-characters} to @code{nil} in the current buffer | |
773 so that they will be interpreted properly. @code{raw-text} handles | |
774 end-of-line conversion in the usual way, based on the data | |
775 encountered, and has the usual three variants to specify the kind of | |
776 end-of-line conversion to use. | |
777 | |
778 In contrast, the coding system @code{no-conversion} specifies no | |
779 character code conversion at all---none for non-@acronym{ASCII} byte values and | |
780 none for end of line. This is useful for reading or writing binary | |
781 files, tar files, and other files that must be examined verbatim. It, | |
782 too, sets @code{enable-multibyte-characters} to @code{nil}. | |
783 | |
784 The easiest way to edit a file with no conversion of any kind is with | |
785 the @kbd{M-x find-file-literally} command. This uses | |
786 @code{no-conversion}, and also suppresses other Emacs features that | |
787 might convert the file contents before you see them. @xref{Visiting}. | |
788 | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
789 The coding system @code{emacs-internal} (or @code{utf-8-emacs}, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
790 which is equivalent) means that the file contains non-@acronym{ASCII} |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
791 characters stored with the internal Emacs encoding. This coding |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
792 system handles end-of-line conversion based on the data encountered, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
793 and has the usual three variants to specify the kind of end-of-line |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
794 conversion. |
84260 | 795 |
796 @node Recognize Coding | |
797 @section Recognizing Coding Systems | |
798 | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
799 Whenever Emacs reads a given piece of text, it tries to recognize |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
800 which coding system to use. This applies to files being read, output |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
801 from subprocesses, text from X selections, etc. Emacs can select the |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
802 right coding system automatically most of the time---once you have |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
803 specified your preferences. |
84260 | 804 |
805 Some coding systems can be recognized or distinguished by which byte | |
806 sequences appear in the data. However, there are coding systems that | |
807 cannot be distinguished, not even potentially. For example, there is no | |
808 way to distinguish between Latin-1 and Latin-2; they use the same byte | |
809 values with different meanings. | |
810 | |
811 Emacs handles this situation by means of a priority list of coding | |
812 systems. Whenever Emacs reads a file, if you do not specify the coding | |
813 system to use, Emacs checks the data against each coding system, | |
814 starting with the first in priority and working down the list, until it | |
815 finds a coding system that fits the data. Then it converts the file | |
816 contents assuming that they are represented in this coding system. | |
817 | |
818 The priority list of coding systems depends on the selected language | |
819 environment (@pxref{Language Environments}). For example, if you use | |
820 French, you probably want Emacs to prefer Latin-1 to Latin-2; if you use | |
821 Czech, you probably want Latin-2 to be preferred. This is one of the | |
822 reasons to specify a language environment. | |
823 | |
824 @findex prefer-coding-system | |
825 However, you can alter the coding system priority list in detail | |
826 with the command @kbd{M-x prefer-coding-system}. This command reads | |
827 the name of a coding system from the minibuffer, and adds it to the | |
828 front of the priority list, so that it is preferred to all others. If | |
829 you use this command several times, each use adds one element to the | |
830 front of the priority list. | |
831 | |
832 If you use a coding system that specifies the end-of-line conversion | |
833 type, such as @code{iso-8859-1-dos}, what this means is that Emacs | |
834 should attempt to recognize @code{iso-8859-1} with priority, and should | |
835 use DOS end-of-line conversion when it does recognize @code{iso-8859-1}. | |
836 | |
837 @vindex file-coding-system-alist | |
838 Sometimes a file name indicates which coding system to use for the | |
839 file. The variable @code{file-coding-system-alist} specifies this | |
840 correspondence. There is a special function | |
841 @code{modify-coding-system-alist} for adding elements to this list. For | |
842 example, to read and write all @samp{.txt} files using the coding system | |
843 @code{chinese-iso-8bit}, you can execute this Lisp expression: | |
844 | |
845 @smallexample | |
846 (modify-coding-system-alist 'file "\\.txt\\'" 'chinese-iso-8bit) | |
847 @end smallexample | |
848 | |
849 @noindent | |
850 The first argument should be @code{file}, the second argument should be | |
851 a regular expression that determines which files this applies to, and | |
852 the third argument says which coding system to use for these files. | |
853 | |
854 @vindex inhibit-eol-conversion | |
855 @cindex DOS-style end-of-line display | |
856 Emacs recognizes which kind of end-of-line conversion to use based on | |
857 the contents of the file: if it sees only carriage-returns, or only | |
858 carriage-return linefeed sequences, then it chooses the end-of-line | |
859 conversion accordingly. You can inhibit the automatic use of | |
860 end-of-line conversion by setting the variable @code{inhibit-eol-conversion} | |
861 to non-@code{nil}. If you do that, DOS-style files will be displayed | |
862 with the @samp{^M} characters visible in the buffer; some people | |
863 prefer this to the more subtle @samp{(DOS)} end-of-line type | |
864 indication near the left edge of the mode line (@pxref{Mode Line, | |
865 eol-mnemonic}). | |
866 | |
867 @vindex inhibit-iso-escape-detection | |
868 @cindex escape sequences in files | |
869 By default, the automatic detection of coding system is sensitive to | |
870 escape sequences. If Emacs sees a sequence of characters that begin | |
871 with an escape character, and the sequence is valid as an ISO-2022 | |
872 code, that tells Emacs to use one of the ISO-2022 encodings to decode | |
873 the file. | |
874 | |
875 However, there may be cases that you want to read escape sequences | |
876 in a file as is. In such a case, you can set the variable | |
877 @code{inhibit-iso-escape-detection} to non-@code{nil}. Then the code | |
878 detection ignores any escape sequences, and never uses an ISO-2022 | |
879 encoding. The result is that all escape sequences become visible in | |
880 the buffer. | |
881 | |
882 The default value of @code{inhibit-iso-escape-detection} is | |
883 @code{nil}. We recommend that you not change it permanently, only for | |
884 one specific operation. That's because many Emacs Lisp source files | |
885 in the Emacs distribution contain non-@acronym{ASCII} characters encoded in the | |
886 coding system @code{iso-2022-7bit}, and they won't be | |
887 decoded correctly when you visit those files if you suppress the | |
888 escape sequence detection. | |
889 | |
890 @vindex auto-coding-alist | |
891 @vindex auto-coding-regexp-alist | |
892 @vindex auto-coding-functions | |
893 The variables @code{auto-coding-alist}, | |
894 @code{auto-coding-regexp-alist} and @code{auto-coding-functions} are | |
895 the strongest way to specify the coding system for certain patterns of | |
896 file names, or for files containing certain patterns; these variables | |
897 even override @samp{-*-coding:-*-} tags in the file itself. Emacs | |
898 uses @code{auto-coding-alist} for tar and archive files, to prevent it | |
899 from being confused by a @samp{-*-coding:-*-} tag in a member of the | |
900 archive and thinking it applies to the archive file as a whole. | |
901 Likewise, Emacs uses @code{auto-coding-regexp-alist} to ensure that | |
902 RMAIL files, whose names in general don't match any particular | |
903 pattern, are decoded correctly. One of the builtin | |
904 @code{auto-coding-functions} detects the encoding for XML files. | |
905 | |
906 @vindex rmail-decode-mime-charset | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
907 @vindex rmail-file-coding-system |
84260 | 908 When you get new mail in Rmail, each message is translated |
909 automatically from the coding system it is written in, as if it were a | |
910 separate file. This uses the priority list of coding systems that you | |
911 have specified. If a MIME message specifies a character set, Rmail | |
912 obeys that specification, unless @code{rmail-decode-mime-charset} is | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
913 @code{nil}. For reading and saving Rmail files themselves, Emacs uses |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
914 the coding system specified by the variable |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
915 @code{rmail-file-coding-system}. The default value is @code{nil}, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
916 which means that Rmail files are not translated (they are read and |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
917 written in the Emacs internal character code). |
84260 | 918 |
919 @node Specify Coding | |
920 @section Specifying a File's Coding System | |
921 | |
922 If Emacs recognizes the encoding of a file incorrectly, you can | |
923 reread the file using the correct coding system by typing @kbd{C-x | |
924 @key{RET} r @var{coding-system} @key{RET}}. To see what coding system | |
925 Emacs actually used to decode the file, look at the coding system | |
926 mnemonic letter near the left edge of the mode line (@pxref{Mode | |
927 Line}), or type @kbd{C-h C @key{RET}}. | |
928 | |
929 @vindex coding | |
930 You can specify the coding system for a particular file in the file | |
931 itself, using the @w{@samp{-*-@dots{}-*-}} construct at the beginning, | |
932 or a local variables list at the end (@pxref{File Variables}). You do | |
933 this by defining a value for the ``variable'' named @code{coding}. | |
934 Emacs does not really have a variable @code{coding}; instead of | |
935 setting a variable, this uses the specified coding system for the | |
936 file. For example, @samp{-*-mode: C; coding: latin-1;-*-} specifies | |
937 use of the Latin-1 coding system, as well as C mode. When you specify | |
938 the coding explicitly in the file, that overrides | |
939 @code{file-coding-system-alist}. | |
940 | |
941 @node Output Coding | |
942 @section Choosing Coding Systems for Output | |
943 | |
944 @vindex buffer-file-coding-system | |
945 Once Emacs has chosen a coding system for a buffer, it stores that | |
946 coding system in @code{buffer-file-coding-system}. That makes it the | |
947 default for operations that write from this buffer into a file, such | |
948 as @code{save-buffer} and @code{write-region}. You can specify a | |
949 different coding system for further file output from the buffer using | |
950 @code{set-buffer-file-coding-system} (@pxref{Text Coding}). | |
951 | |
952 You can insert any character Emacs supports into any Emacs buffer, | |
953 but most coding systems can only handle a subset of these characters. | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
954 Therefore, it's possible that the characters you insert cannot be |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
955 encoded with the coding system that will be used to save the buffer. |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
956 For example, you could visit a text file in Polish, encoded in |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
957 @code{iso-8859-2}, and add some Russian words to it. When you save |
84260 | 958 that buffer, Emacs cannot use the current value of |
959 @code{buffer-file-coding-system}, because the characters you added | |
960 cannot be encoded by that coding system. | |
961 | |
962 When that happens, Emacs tries the most-preferred coding system (set | |
963 by @kbd{M-x prefer-coding-system} or @kbd{M-x | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
964 set-language-environment}). If that coding system can safely encode |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
965 all of the characters in the buffer, Emacs uses it, and stores its |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
966 value in @code{buffer-file-coding-system}. Otherwise, Emacs displays |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
967 a list of coding systems suitable for encoding the buffer's contents, |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
968 and asks you to choose one of those coding systems. |
84260 | 969 |
970 If you insert the unsuitable characters in a mail message, Emacs | |
971 behaves a bit differently. It additionally checks whether the | |
972 most-preferred coding system is recommended for use in MIME messages; | |
973 if not, Emacs tells you that the most-preferred coding system is not | |
974 recommended and prompts you for another coding system. This is so you | |
975 won't inadvertently send a message encoded in a way that your | |
976 recipient's mail software will have difficulty decoding. (You can | |
977 still use an unsuitable coding system if you type its name in response | |
978 to the question.) | |
979 | |
980 @vindex sendmail-coding-system | |
981 When you send a message with Mail mode (@pxref{Sending Mail}), Emacs has | |
982 four different ways to determine the coding system to use for encoding | |
983 the message text. It tries the buffer's own value of | |
984 @code{buffer-file-coding-system}, if that is non-@code{nil}. Otherwise, | |
985 it uses the value of @code{sendmail-coding-system}, if that is | |
986 non-@code{nil}. The third way is to use the default coding system for | |
987 new files, which is controlled by your choice of language environment, | |
988 if that is non-@code{nil}. If all of these three values are @code{nil}, | |
989 Emacs encodes outgoing mail using the Latin-1 coding system. | |
990 | |
991 @node Text Coding | |
992 @section Specifying a Coding System for File Text | |
993 | |
994 In cases where Emacs does not automatically choose the right coding | |
995 system for a file's contents, you can use these commands to specify | |
996 one: | |
997 | |
998 @table @kbd | |
999 @item C-x @key{RET} f @var{coding} @key{RET} | |
1000 Use coding system @var{coding} for saving or revisiting the visited | |
1001 file in the current buffer. | |
1002 | |
1003 @item C-x @key{RET} c @var{coding} @key{RET} | |
1004 Specify coding system @var{coding} for the immediately following | |
1005 command. | |
1006 | |
1007 @item C-x @key{RET} r @var{coding} @key{RET} | |
1008 Revisit the current file using the coding system @var{coding}. | |
1009 | |
1010 @item M-x recode-region @key{RET} @var{right} @key{RET} @var{wrong} @key{RET} | |
1011 Convert a region that was decoded using coding system @var{wrong}, | |
1012 decoding it using coding system @var{right} instead. | |
1013 @end table | |
1014 | |
1015 @kindex C-x RET f | |
1016 @findex set-buffer-file-coding-system | |
1017 The command @kbd{C-x @key{RET} f} | |
1018 (@code{set-buffer-file-coding-system}) sets the file coding system for | |
1019 the current buffer---in other words, it says which coding system to | |
1020 use when saving or reverting the visited file. You specify which | |
1021 coding system using the minibuffer. If you specify a coding system | |
1022 that cannot handle all of the characters in the buffer, Emacs warns | |
1023 you about the troublesome characters when you actually save the | |
1024 buffer. | |
1025 | |
1026 @cindex specify end-of-line conversion | |
1027 You can also use this command to specify the end-of-line conversion | |
1028 (@pxref{Coding Systems, end-of-line conversion}) for encoding the | |
1029 current buffer. For example, @kbd{C-x @key{RET} f dos @key{RET}} will | |
1030 cause Emacs to save the current buffer's text with DOS-style CRLF line | |
1031 endings. | |
1032 | |
1033 @kindex C-x RET c | |
1034 @findex universal-coding-system-argument | |
1035 Another way to specify the coding system for a file is when you visit | |
1036 the file. First use the command @kbd{C-x @key{RET} c} | |
1037 (@code{universal-coding-system-argument}); this command uses the | |
1038 minibuffer to read a coding system name. After you exit the minibuffer, | |
1039 the specified coding system is used for @emph{the immediately following | |
1040 command}. | |
1041 | |
1042 So if the immediately following command is @kbd{C-x C-f}, for example, | |
1043 it reads the file using that coding system (and records the coding | |
1044 system for when you later save the file). Or if the immediately following | |
1045 command is @kbd{C-x C-w}, it writes the file using that coding system. | |
1046 When you specify the coding system for saving in this way, instead | |
1047 of with @kbd{C-x @key{RET} f}, there is no warning if the buffer | |
1048 contains characters that the coding system cannot handle. | |
1049 | |
1050 Other file commands affected by a specified coding system include | |
1051 @kbd{C-x i} and @kbd{C-x C-v}, as well as the other-window variants | |
1052 of @kbd{C-x C-f}. @kbd{C-x @key{RET} c} also affects commands that | |
1053 start subprocesses, including @kbd{M-x shell} (@pxref{Shell}). If the | |
1054 immediately following command does not use the coding system, then | |
1055 @kbd{C-x @key{RET} c} ultimately has no effect. | |
1056 | |
1057 An easy way to visit a file with no conversion is with the @kbd{M-x | |
1058 find-file-literally} command. @xref{Visiting}. | |
1059 | |
1060 @vindex default-buffer-file-coding-system | |
1061 The variable @code{default-buffer-file-coding-system} specifies the | |
1062 choice of coding system to use when you create a new file. It applies | |
1063 when you find a new file, and when you create a buffer and then save it | |
1064 in a file. Selecting a language environment typically sets this | |
1065 variable to a good choice of default coding system for that language | |
1066 environment. | |
1067 | |
1068 @kindex C-x RET r | |
1069 @findex revert-buffer-with-coding-system | |
1070 If you visit a file with a wrong coding system, you can correct this | |
1071 with @kbd{C-x @key{RET} r} (@code{revert-buffer-with-coding-system}). | |
1072 This visits the current file again, using a coding system you specify. | |
1073 | |
1074 @findex recode-region | |
1075 If a piece of text has already been inserted into a buffer using the | |
1076 wrong coding system, you can redo the decoding of it using @kbd{M-x | |
1077 recode-region}. This prompts you for the proper coding system, then | |
1078 for the wrong coding system that was actually used, and does the | |
1079 conversion. It first encodes the region using the wrong coding system, | |
1080 then decodes it again using the proper coding system. | |
1081 | |
1082 @node Communication Coding | |
1083 @section Coding Systems for Interprocess Communication | |
1084 | |
1085 This section explains how to specify coding systems for use | |
1086 in communication with other processes. | |
1087 | |
1088 @table @kbd | |
1089 @item C-x @key{RET} x @var{coding} @key{RET} | |
1090 Use coding system @var{coding} for transferring selections to and from | |
1091 other window-based applications. | |
1092 | |
1093 @item C-x @key{RET} X @var{coding} @key{RET} | |
1094 Use coding system @var{coding} for transferring @emph{one} | |
1095 selection---the next one---to or from another window-based application. | |
1096 | |
1097 @item C-x @key{RET} p @var{input-coding} @key{RET} @var{output-coding} @key{RET} | |
1098 Use coding systems @var{input-coding} and @var{output-coding} for | |
1099 subprocess input and output in the current buffer. | |
1100 | |
1101 @item C-x @key{RET} c @var{coding} @key{RET} | |
1102 Specify coding system @var{coding} for the immediately following | |
1103 command. | |
1104 @end table | |
1105 | |
1106 @kindex C-x RET x | |
1107 @kindex C-x RET X | |
1108 @findex set-selection-coding-system | |
1109 @findex set-next-selection-coding-system | |
1110 The command @kbd{C-x @key{RET} x} (@code{set-selection-coding-system}) | |
1111 specifies the coding system for sending selected text to other windowing | |
1112 applications, and for receiving the text of selections made in other | |
1113 applications. This command applies to all subsequent selections, until | |
1114 you override it by using the command again. The command @kbd{C-x | |
1115 @key{RET} X} (@code{set-next-selection-coding-system}) specifies the | |
1116 coding system for the next selection made in Emacs or read by Emacs. | |
1117 | |
86142
636dd9f953e5
(Communication Coding): Mention x-select-request-type.
Kenichi Handa <handa@m17n.org>
parents:
85934
diff
changeset
|
1118 @vindex x-select-request-type |
86196
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1119 The variable @code{x-select-request-type} specifies the data type to |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1120 request from the X Window System for receiving text selections from |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1121 other applications. If the value is @code{nil} (the default), Emacs |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1122 tries @code{COMPOUND_TEXT} and @code{UTF8_STRING}, in this order, and |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1123 uses various heuristics to choose the more appropriate of the two |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1124 results; if none of these succeed, Emacs falls back on @code{STRING}. |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1125 If the value of @code{x-select-request-type} is one of the symbols |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1126 @code{COMPOUND_TEXT}, @code{UTF8_STRING}, @code{STRING}, or |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1127 @code{TEXT}, Emacs uses only that request type. If the value is a |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1128 list of some of these symbols, Emacs tries only the request types in |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1129 the list, in order, until one of them succeeds, or until the list is |
de09b9f093a0
(Communication Coding): Fix wording of last change.
Eli Zaretskii <eliz@gnu.org>
parents:
86142
diff
changeset
|
1130 exhausted. |
86142
636dd9f953e5
(Communication Coding): Mention x-select-request-type.
Kenichi Handa <handa@m17n.org>
parents:
85934
diff
changeset
|
1131 |
84260 | 1132 @kindex C-x RET p |
1133 @findex set-buffer-process-coding-system | |
1134 The command @kbd{C-x @key{RET} p} (@code{set-buffer-process-coding-system}) | |
1135 specifies the coding system for input and output to a subprocess. This | |
1136 command applies to the current buffer; normally, each subprocess has its | |
1137 own buffer, and thus you can use this command to specify translation to | |
1138 and from a particular subprocess by giving the command in the | |
1139 corresponding buffer. | |
1140 | |
1141 You can also use @kbd{C-x @key{RET} c} just before the command that | |
1142 runs or starts a subprocess, to specify the coding system to use for | |
1143 communication with that subprocess. | |
1144 | |
1145 The default for translation of process input and output depends on the | |
1146 current language environment. | |
1147 | |
1148 @vindex locale-coding-system | |
1149 @cindex decoding non-@acronym{ASCII} keyboard input on X | |
1150 The variable @code{locale-coding-system} specifies a coding system | |
1151 to use when encoding and decoding system strings such as system error | |
1152 messages and @code{format-time-string} formats and time stamps. That | |
1153 coding system is also used for decoding non-@acronym{ASCII} keyboard input on X | |
1154 Window systems. You should choose a coding system that is compatible | |
1155 with the underlying system's text representation, which is normally | |
1156 specified by one of the environment variables @env{LC_ALL}, | |
1157 @env{LC_CTYPE}, and @env{LANG}. (The first one, in the order | |
1158 specified above, whose value is nonempty is the one that determines | |
1159 the text representation.) | |
1160 | |
86275 | 1161 @vindex x-select-request-type |
1162 The variable @code{x-select-request-type} specifies a selection data | |
1163 type of selection to request from the X server. The default value is | |
1164 @code{nil}, which means Emacs tries @code{COMPOUND_TEXT} and | |
1165 @code{UTF8_STRING}, and uses whichever result seems more appropriate. | |
1166 You can explicitly specify the data type by setting the variable to | |
1167 one of the symbols @code{COMPOUND_TEXT}, @code{UTF8_STRING}, | |
1168 @code{STRING} and @code{TEXT}. | |
1169 | |
84260 | 1170 @node File Name Coding |
1171 @section Coding Systems for File Names | |
1172 | |
1173 @table @kbd | |
1174 @item C-x @key{RET} F @var{coding} @key{RET} | |
1175 Use coding system @var{coding} for encoding and decoding file | |
1176 @emph{names}. | |
1177 @end table | |
1178 | |
1179 @vindex file-name-coding-system | |
1180 @cindex file names with non-@acronym{ASCII} characters | |
1181 The variable @code{file-name-coding-system} specifies a coding | |
1182 system to use for encoding file names. It has no effect on reading | |
1183 and writing the @emph{contents} of files. | |
1184 | |
1185 @findex set-file-name-coding-system | |
1186 @kindex C-x @key{RET} F | |
1187 If you set the variable to a coding system name (as a Lisp symbol or | |
1188 a string), Emacs encodes file names using that coding system for all | |
1189 file operations. This makes it possible to use non-@acronym{ASCII} | |
1190 characters in file names---or, at least, those non-@acronym{ASCII} | |
1191 characters which the specified coding system can encode. Use @kbd{C-x | |
1192 @key{RET} F} (@code{set-file-name-coding-system}) to specify this | |
1193 interactively. | |
1194 | |
1195 If @code{file-name-coding-system} is @code{nil}, Emacs uses a | |
1196 default coding system determined by the selected language environment. | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
1197 In the default language environment, non-@acronym{ASCII} characters in |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
1198 file names are not encoded specially; they appear in the file system |
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
1199 using the internal Emacs representation. |
84260 | 1200 |
1201 @strong{Warning:} if you change @code{file-name-coding-system} (or the | |
1202 language environment) in the middle of an Emacs session, problems can | |
1203 result if you have already visited files whose names were encoded using | |
1204 the earlier coding system and cannot be encoded (or are encoded | |
1205 differently) under the new coding system. If you try to save one of | |
1206 these buffers under the visited file name, saving may use the wrong file | |
1207 name, or it may get an error. If such a problem happens, use @kbd{C-x | |
1208 C-w} to specify a new file name for that buffer. | |
1209 | |
1210 @findex recode-file-name | |
1211 If a mistake occurs when encoding a file name, use the command | |
1212 @kbd{M-x recode-file-name} to change the file name's coding | |
1213 system. This prompts for an existing file name, its old coding | |
1214 system, and the coding system to which you wish to convert. | |
1215 | |
1216 @node Terminal Coding | |
1217 @section Coding Systems for Terminal I/O | |
1218 | |
1219 @table @kbd | |
1220 @item C-x @key{RET} k @var{coding} @key{RET} | |
1221 Use coding system @var{coding} for keyboard input. | |
1222 | |
1223 @item C-x @key{RET} t @var{coding} @key{RET} | |
1224 Use coding system @var{coding} for terminal output. | |
1225 @end table | |
1226 | |
1227 @kindex C-x RET t | |
1228 @findex set-terminal-coding-system | |
1229 The command @kbd{C-x @key{RET} t} (@code{set-terminal-coding-system}) | |
1230 specifies the coding system for terminal output. If you specify a | |
1231 character code for terminal output, all characters output to the | |
1232 terminal are translated into that coding system. | |
1233 | |
1234 This feature is useful for certain character-only terminals built to | |
1235 support specific languages or character sets---for example, European | |
1236 terminals that support one of the ISO Latin character sets. You need to | |
1237 specify the terminal coding system when using multibyte text, so that | |
1238 Emacs knows which characters the terminal can actually handle. | |
1239 | |
1240 By default, output to the terminal is not translated at all, unless | |
1241 Emacs can deduce the proper coding system from your terminal type or | |
1242 your locale specification (@pxref{Language Environments}). | |
1243 | |
1244 @kindex C-x RET k | |
1245 @findex set-keyboard-coding-system | |
1246 @vindex keyboard-coding-system | |
1247 The command @kbd{C-x @key{RET} k} (@code{set-keyboard-coding-system}) | |
1248 or the variable @code{keyboard-coding-system} specifies the coding | |
1249 system for keyboard input. Character-code translation of keyboard | |
1250 input is useful for terminals with keys that send non-@acronym{ASCII} | |
1251 graphic characters---for example, some terminals designed for ISO | |
1252 Latin-1 or subsets of it. | |
1253 | |
1254 By default, keyboard input is translated based on your system locale | |
1255 setting. If your terminal does not really support the encoding | |
1256 implied by your locale (for example, if you find it inserts a | |
1257 non-@acronym{ASCII} character if you type @kbd{M-i}), you will need to set | |
1258 @code{keyboard-coding-system} to @code{nil} to turn off encoding. | |
1259 You can do this by putting | |
1260 | |
1261 @lisp | |
1262 (set-keyboard-coding-system nil) | |
1263 @end lisp | |
1264 | |
1265 @noindent | |
103164
59c06c5e090e
* basic.texi (Inserting Text): Document ucs-insert.
Chong Yidong <cyd@stupidchicken.com>
parents:
102247
diff
changeset
|
1266 in your init file. |
84260 | 1267 |
1268 There is a similarity between using a coding system translation for | |
1269 keyboard input, and using an input method: both define sequences of | |
1270 keyboard input that translate into single characters. However, input | |
1271 methods are designed to be convenient for interactive use by humans, and | |
1272 the sequences that are translated are typically sequences of @acronym{ASCII} | |
1273 printing characters. Coding systems typically translate sequences of | |
1274 non-graphic characters. | |
1275 | |
1276 @node Fontsets | |
1277 @section Fontsets | |
1278 @cindex fontsets | |
1279 | |
1280 A font typically defines shapes for a single alphabet or script. | |
1281 Therefore, displaying the entire range of scripts that Emacs supports | |
1282 requires a collection of many fonts. In Emacs, such a collection is | |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1283 called a @dfn{fontset}. A fontset is defined by a list of font specs, |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1284 each assigned to handle a range of character codes, and may fall back |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1285 on another fontset for characters which are not covered by the fonts |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1286 it specifies. |
84260 | 1287 |
1288 Each fontset has a name, like a font. However, while fonts are | |
1289 stored in the system and the available font names are defined by the | |
1290 system, fontsets are defined within Emacs itself. Once you have | |
1291 defined a fontset, you can use it within Emacs by specifying its name, | |
1292 anywhere that you could use a single font. Of course, Emacs fontsets | |
1293 can use only the fonts that the system supports; if certain characters | |
1294 appear on the screen as hollow boxes, this means that the fontset in | |
1295 use for them has no font for those characters.@footnote{The Emacs | |
1296 installation instructions have information on additional font | |
1297 support.} | |
1298 | |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1299 Emacs creates three fontsets automatically: the @dfn{standard |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1300 fontset}, the @dfn{startup fontset} and the @dfn{default fontset}. |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1301 The default fontset is most likely to have fonts for a wide variety of |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1302 non-@acronym{ASCII} characters and is the default fallback for the |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1303 other two fontsets, and if you set a default font rather than fontset. |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1304 However it does not specify font family names, so results can be |
102247
b4a117181d97
(Fontsets): Correction to fontset-standard description.
Jason Rumney <jasonr@gnu.org>
parents:
102245
diff
changeset
|
1305 somewhat random if you use it directly. You can specify use of a |
b4a117181d97
(Fontsets): Correction to fontset-standard description.
Jason Rumney <jasonr@gnu.org>
parents:
102245
diff
changeset
|
1306 specific fontset with the @samp{-fn} option. For example, |
84260 | 1307 |
1308 @example | |
1309 emacs -fn fontset-standard | |
1310 @end example | |
1311 | |
1312 @noindent | |
1313 You can also specify a fontset with the @samp{Font} resource (@pxref{X | |
1314 Resources}). | |
1315 | |
102247
b4a117181d97
(Fontsets): Correction to fontset-standard description.
Jason Rumney <jasonr@gnu.org>
parents:
102245
diff
changeset
|
1316 If no fontset is specified for use, then Emacs uses an |
b4a117181d97
(Fontsets): Correction to fontset-standard description.
Jason Rumney <jasonr@gnu.org>
parents:
102245
diff
changeset
|
1317 @acronym{ASCII} font, with @samp{fontset-default} as a fallback for |
b4a117181d97
(Fontsets): Correction to fontset-standard description.
Jason Rumney <jasonr@gnu.org>
parents:
102245
diff
changeset
|
1318 characters the font does not cover. The standard fontset is only used if |
b4a117181d97
(Fontsets): Correction to fontset-standard description.
Jason Rumney <jasonr@gnu.org>
parents:
102245
diff
changeset
|
1319 explicitly requested, despite its name. |
b4a117181d97
(Fontsets): Correction to fontset-standard description.
Jason Rumney <jasonr@gnu.org>
parents:
102245
diff
changeset
|
1320 |
84260 | 1321 A fontset does not necessarily specify a font for every character |
1322 code. If a fontset specifies no font for a certain character, or if it | |
1323 specifies a font that does not exist on your system, then it cannot | |
1324 display that character properly. It will display that character as an | |
1325 empty box instead. | |
1326 | |
1327 @node Defining Fontsets | |
1328 @section Defining fontsets | |
1329 | |
1330 @vindex standard-fontset-spec | |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1331 @vindex w32-standard-fontset-spec |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1332 @vindex ns-standard-fontset-spec |
84260 | 1333 @cindex standard fontset |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1334 When running on X, Emacs creates a standard fontset automatically according to the value |
84260 | 1335 of @code{standard-fontset-spec}. This fontset's name is |
1336 | |
1337 @example | |
1338 -*-fixed-medium-r-normal-*-16-*-*-*-*-*-fontset-standard | |
1339 @end example | |
1340 | |
1341 @noindent | |
1342 or just @samp{fontset-standard} for short. | |
1343 | |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1344 On GNUstep and Mac, fontset-standard is created using the value of |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1345 @code{ns-standard-fontset-spec}, and on Windows it is |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1346 created using the value of @code{w32-standard-fontset-spec}. |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1347 |
84260 | 1348 Bold, italic, and bold-italic variants of the standard fontset are |
1349 created automatically. Their names have @samp{bold} instead of | |
1350 @samp{medium}, or @samp{i} instead of @samp{r}, or both. | |
1351 | |
1352 @cindex startup fontset | |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1353 Emacs generates a fontset automatically, based on any default |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1354 @acronym{ASCII} font that you specify with the @samp{Font} resource or |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1355 the @samp{-fn} argument, or the default font that Emacs found when it |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1356 started. This is the @dfn{startup fontset} and its name is |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1357 @code{fontset-startup}. It does this by replacing the |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1358 @var{charset_registry} field with @samp{fontset}, and replacing |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1359 @var{charset_encoding} field with @samp{startup}, then using the |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1360 resulting string to specify a fontset. |
84260 | 1361 |
1362 For instance, if you start Emacs this way, | |
1363 | |
1364 @example | |
1365 emacs -fn "*courier-medium-r-normal--14-140-*-iso8859-1" | |
1366 @end example | |
1367 | |
1368 @noindent | |
1369 Emacs generates the following fontset and uses it for the initial X | |
1370 window frame: | |
1371 | |
1372 @example | |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1373 -*-courier-medium-r-normal-*-14-140-*-*-*-*-fontset-startup |
84260 | 1374 @end example |
1375 | |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1376 The startup fontset will use the font that you specify or a variant |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1377 with a different registry and encoding for all the characters which |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1378 are supported by that font, and fallback on @samp{fontset-default} for |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1379 other characters. |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1380 |
84260 | 1381 With the X resource @samp{Emacs.Font}, you can specify a fontset name |
1382 just like an actual font name. But be careful not to specify a fontset | |
1383 name in a wildcard resource like @samp{Emacs*Font}---that wildcard | |
1384 specification matches various other resources, such as for menus, and | |
1385 menus cannot handle fontsets. | |
1386 | |
1387 You can specify additional fontsets using X resources named | |
1388 @samp{Fontset-@var{n}}, where @var{n} is an integer starting from 0. | |
1389 The resource value should have this form: | |
1390 | |
1391 @smallexample | |
1392 @var{fontpattern}, @r{[}@var{charset}:@var{font}@r{]@dots{}} | |
1393 @end smallexample | |
1394 | |
1395 @noindent | |
1396 @var{fontpattern} should have the form of a standard X font name, except | |
1397 for the last two fields. They should have the form | |
1398 @samp{fontset-@var{alias}}. | |
1399 | |
1400 The fontset has two names, one long and one short. The long name is | |
1401 @var{fontpattern}. The short name is @samp{fontset-@var{alias}}. You | |
1402 can refer to the fontset by either name. | |
1403 | |
1404 The construct @samp{@var{charset}:@var{font}} specifies which font to | |
1405 use (in this fontset) for one particular character set. Here, | |
1406 @var{charset} is the name of a character set, and @var{font} is the | |
1407 font to use for that character set. You can use this construct any | |
1408 number of times in defining one fontset. | |
1409 | |
1410 For the other character sets, Emacs chooses a font based on | |
1411 @var{fontpattern}. It replaces @samp{fontset-@var{alias}} with values | |
1412 that describe the character set. For the @acronym{ASCII} character font, | |
1413 @samp{fontset-@var{alias}} is replaced with @samp{ISO8859-1}. | |
1414 | |
1415 In addition, when several consecutive fields are wildcards, Emacs | |
1416 collapses them into a single wildcard. This is to prevent use of | |
1417 auto-scaled fonts. Fonts made by scaling larger fonts are not usable | |
1418 for editing, and scaling a smaller font is not useful because it is | |
1419 better to use the smaller font in its own size, which is what Emacs | |
1420 does. | |
1421 | |
1422 Thus if @var{fontpattern} is this, | |
1423 | |
1424 @example | |
1425 -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24 | |
1426 @end example | |
1427 | |
1428 @noindent | |
1429 the font specification for @acronym{ASCII} characters would be this: | |
1430 | |
1431 @example | |
1432 -*-fixed-medium-r-normal-*-24-*-ISO8859-1 | |
1433 @end example | |
1434 | |
1435 @noindent | |
1436 and the font specification for Chinese GB2312 characters would be this: | |
1437 | |
1438 @example | |
1439 -*-fixed-medium-r-normal-*-24-*-gb2312*-* | |
1440 @end example | |
1441 | |
1442 You may not have any Chinese font matching the above font | |
1443 specification. Most X distributions include only Chinese fonts that | |
1444 have @samp{song ti} or @samp{fangsong ti} in @var{family} field. In | |
1445 such a case, @samp{Fontset-@var{n}} can be specified as below: | |
1446 | |
1447 @smallexample | |
1448 Emacs.Fontset-0: -*-fixed-medium-r-normal-*-24-*-*-*-*-*-fontset-24,\ | |
1449 chinese-gb2312:-*-*-medium-r-normal-*-24-*-gb2312*-* | |
1450 @end smallexample | |
1451 | |
1452 @noindent | |
1453 Then, the font specifications for all but Chinese GB2312 characters have | |
1454 @samp{fixed} in the @var{family} field, and the font specification for | |
1455 Chinese GB2312 characters has a wild card @samp{*} in the @var{family} | |
1456 field. | |
1457 | |
1458 @findex create-fontset-from-fontset-spec | |
1459 The function that processes the fontset resource value to create the | |
1460 fontset is called @code{create-fontset-from-fontset-spec}. You can also | |
1461 call this function explicitly to create a fontset. | |
1462 | |
1463 @xref{Font X}, for more information about font naming in X. | |
1464 | |
102244
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1465 @node Modifying Fontsets |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1466 @section Modifying Fontsets |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1467 @cindex fontsets, modifying |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1468 @findex set-fontset-font |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1469 |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1470 Fontsets do not always have to be created from scratch. If only |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1471 minor changes are required it may be easier to modify an existing |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1472 fontset. Modifying @samp{fontset-default} will also affect other |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1473 fontsets that use it as a fallback, so can be an effective way of |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1474 fixing problems with the fonts that Emacs chooses for a particular |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1475 script. |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1476 |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1477 Fontsets can be modified using the function @code{set-fontset-font}, |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1478 specifying a character, a charset, a script, or a range of characters |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1479 to modify the font for, and a font-spec for the font to be used. Some |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1480 examples are: |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1481 |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1482 @example |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1483 ;; Use Liberation Mono for latin-3 charset. |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1484 (set-fontset-font "fontset-default" 'iso-8859-3 "Liberation Mono") |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1485 |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1486 ;; Prefer a big5 font for han characters |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1487 (set-fontset-font "fontset-default" 'han (font-spec :registry "big5") |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1488 nil 'prepend) |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1489 |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1490 ;; Use DejaVu Sans Mono as a fallback in fontset-startup before |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1491 ;; resorting to fontset-default. |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1492 (set-fontset-font "fontset-startup" nil "DejaVu Sans Mono" nil 'append) |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1493 |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1494 ;; Use MyPrivateFont for the Unicode private use area. |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1495 (set-fontset-font "fontset-default" '(#xe000 . #xf8ff) "MyPrivateFont") |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1496 |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1497 @end example |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1498 |
a4d5437cec4d
(Fontsets): Mention fontset-default, font specs and fallback fontsets.
Jason Rumney <jasonr@gnu.org>
parents:
100974
diff
changeset
|
1499 |
84260 | 1500 @node Undisplayable Characters |
1501 @section Undisplayable Characters | |
1502 | |
1503 There may be a some non-@acronym{ASCII} characters that your terminal cannot | |
1504 display. Most text-only terminals support just a single character | |
1505 set (use the variable @code{default-terminal-coding-system} | |
1506 (@pxref{Terminal Coding}) to tell Emacs which one); characters which | |
1507 can't be encoded in that coding system are displayed as @samp{?} by | |
1508 default. | |
1509 | |
1510 Graphical displays can display a broader range of characters, but | |
1511 you may not have fonts installed for all of them; characters that have | |
1512 no font appear as a hollow box. | |
1513 | |
1514 If you use Latin-1 characters but your terminal can't display | |
1515 Latin-1, you can arrange to display mnemonic @acronym{ASCII} sequences | |
1516 instead, e.g.@: @samp{"o} for o-umlaut. Load the library | |
1517 @file{iso-ascii} to do this. | |
1518 | |
1519 @vindex latin1-display | |
1520 If your terminal can display Latin-1, you can display characters | |
1521 from other European character sets using a mixture of equivalent | |
1522 Latin-1 characters and @acronym{ASCII} mnemonics. Customize the variable | |
1523 @code{latin1-display} to enable this. The mnemonic @acronym{ASCII} | |
1524 sequences mostly correspond to those of the prefix input methods. | |
1525 | |
1526 @node Unibyte Mode | |
1527 @section Unibyte Editing Mode | |
1528 | |
1529 @cindex European character sets | |
1530 @cindex accented characters | |
1531 @cindex ISO Latin character sets | |
1532 @cindex Unibyte operation | |
1533 The ISO 8859 Latin-@var{n} character sets define character codes in | |
1534 the range 0240 to 0377 octal (160 to 255 decimal) to handle the | |
1535 accented letters and punctuation needed by various European languages | |
1536 (and some non-European ones). If you disable multibyte characters, | |
1537 Emacs can still handle @emph{one} of these character codes at a time. | |
1538 To specify @emph{which} of these codes to use, invoke @kbd{M-x | |
1539 set-language-environment} and specify a suitable language environment | |
1540 such as @samp{Latin-@var{n}}. | |
1541 | |
1542 For more information about unibyte operation, see @ref{Enabling | |
1543 Multibyte}. Note particularly that you probably want to ensure that | |
1544 your initialization files are read as unibyte if they contain | |
1545 non-@acronym{ASCII} characters. | |
1546 | |
1547 @vindex unibyte-display-via-language-environment | |
1548 Emacs can also display those characters, provided the terminal or font | |
1549 in use supports them. This works automatically. Alternatively, on a | |
1550 graphical display, Emacs can also display single-byte characters | |
1551 through fontsets, in effect by displaying the equivalent multibyte | |
1552 characters according to the current language environment. To request | |
1553 this, set the variable @code{unibyte-display-via-language-environment} | |
1554 to a non-@code{nil} value. | |
1555 | |
1556 @cindex @code{iso-ascii} library | |
1557 If your terminal does not support display of the Latin-1 character | |
1558 set, Emacs can display these characters as @acronym{ASCII} sequences which at | |
1559 least give you a clear idea of what the characters are. To do this, | |
1560 load the library @code{iso-ascii}. Similar libraries for other | |
1561 Latin-@var{n} character sets could be implemented, but we don't have | |
1562 them yet. | |
1563 | |
1564 @findex standard-display-8bit | |
1565 @cindex 8-bit display | |
1566 Normally non-ISO-8859 characters (decimal codes between 128 and 159 | |
1567 inclusive) are displayed as octal escapes. You can change this for | |
1568 non-standard ``extended'' versions of ISO-8859 character sets by using the | |
1569 function @code{standard-display-8bit} in the @code{disp-table} library. | |
1570 | |
1571 There are two ways to input single-byte non-@acronym{ASCII} | |
1572 characters: | |
1573 | |
1574 @itemize @bullet | |
1575 @cindex 8-bit input | |
1576 @item | |
1577 You can use an input method for the selected language environment. | |
1578 @xref{Input Methods}. When you use an input method in a unibyte buffer, | |
1579 the non-@acronym{ASCII} character you specify with it is converted to unibyte. | |
1580 | |
1581 @item | |
1582 If your keyboard can generate character codes 128 (decimal) and up, | |
1583 representing non-@acronym{ASCII} characters, you can type those character codes | |
1584 directly. | |
1585 | |
1586 On a graphical display, you should not need to do anything special to use | |
1587 these keys; they should simply work. On a text-only terminal, you | |
1588 should use the command @code{M-x set-keyboard-coding-system} or the | |
1589 variable @code{keyboard-coding-system} to specify which coding system | |
1590 your keyboard uses (@pxref{Terminal Coding}). Enabling this feature | |
1591 will probably require you to use @kbd{ESC} to type Meta characters; | |
1592 however, on a console terminal or in @code{xterm}, you can arrange for | |
1593 Meta to be converted to @kbd{ESC} and still be able type 8-bit | |
1594 characters present directly on the keyboard or using @kbd{Compose} or | |
1595 @kbd{AltGr} keys. @xref{User Input}. | |
1596 | |
1597 @kindex C-x 8 | |
1598 @cindex @code{iso-transl} library | |
1599 @cindex compose character | |
1600 @cindex dead character | |
1601 @item | |
1602 For Latin-1 only, you can use the key @kbd{C-x 8} as a ``compose | |
1603 character'' prefix for entry of non-@acronym{ASCII} Latin-1 printing | |
1604 characters. @kbd{C-x 8} is good for insertion (in the minibuffer as | |
1605 well as other buffers), for searching, and in any other context where | |
1606 a key sequence is allowed. | |
1607 | |
1608 @kbd{C-x 8} works by loading the @code{iso-transl} library. Once that | |
1609 library is loaded, the @key{ALT} modifier key, if the keyboard has | |
1610 one, serves the same purpose as @kbd{C-x 8}: use @key{ALT} together | |
1611 with an accent character to modify the following letter. In addition, | |
1612 if the keyboard has keys for the Latin-1 ``dead accent characters,'' | |
1613 they too are defined to compose with the following character, once | |
1614 @code{iso-transl} is loaded. | |
1615 | |
1616 Use @kbd{C-x 8 C-h} to list all the available @kbd{C-x 8} translations. | |
1617 @end itemize | |
1618 | |
1619 @node Charsets | |
1620 @section Charsets | |
1621 @cindex charsets | |
1622 | |
103450
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1623 Emacs defines most of popular character sets (e.g. ascii, |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1624 iso-8859-1, cp1250, big5, unicode) as @dfn{charsets} and a few of its |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1625 own charsets (e.g. emacs, unicode-bmp, eight-bit). All supported |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1626 characters belong to one or more charsets. Usually you don't have to |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1627 take care of ``charset'', but knowing about it may help understanding |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1628 the behavior of Emacs in some cases. |
84260 | 1629 |
103450
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1630 One example is a font selection. In each language environment, |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1631 charsets have different priorities. Emacs, at first, tries to use a |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1632 font that matches with charsets of higher priority. For instance, in |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1633 Japanese language environment, the charset @code{japanese-jisx0208} |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1634 has the highest priority (@xref{describe-language-environment}). So, |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1635 Emacs tries to use a font whose @code{registry} property is |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1636 ``JISX0208.1983-0'' for characters belonging to that charset. |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1637 |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1638 Another example is a use of @code{charset} text property. When |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1639 Emacs reads a file encoded in a coding systems that uses escape |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1640 sequences to switch charsets (e.g. iso-2022-int-1), the buffer text |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1641 keep the information of the original charset by @code{charset} text |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1642 property. By using this information, Emacs can write the file with |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1643 the same byte sequence as the original. |
84260 | 1644 |
1645 @findex list-charset-chars | |
1646 @cindex characters in a certain charset | |
1647 @findex describe-character-set | |
1648 There are two commands for obtaining information about Emacs | |
103450
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1649 charsets. The command @kbd{M-x list-charset-chars} prompts for a |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1650 charset name, and displays all the characters in that character set. |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1651 The command @kbd{M-x describe-character-set} prompts for a charset |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1652 name and displays information about that charset, including its |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1653 internal representation within Emacs. |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1654 |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1655 @findex list-character-sets |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1656 To display a list of all the supported charsets, type @kbd{M-x |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1657 list-character-sets}. The list gives the names of charsets and |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1658 additional information to identity each charset (see ISO/IEC's this |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1659 page <http://www.itscj.ipsj.or.jp/ISO-IR/> for the detail). In the |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1660 list, charsets are categorized into two; the normal charsets are |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1661 listed first, and the supplementary charsets are listed last. A |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1662 charset in the latter category is used for defining another charset |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1663 (as a parent or a subset), or was used only in Emacs of the older |
79a0347eb272
(Charsets): Update the description for the new charset.
Kenichi Handa <handa@m17n.org>
parents:
103235
diff
changeset
|
1664 versions. |
84260 | 1665 |
1666 To find out which charset a character in the buffer belongs to, | |
1667 put point before it and type @kbd{C-u C-x =}. | |
1668 | |
1669 @ignore | |
1670 arch-tag: 310ba60d-31ef-4ce7-91f1-f282dd57b6b3 | |
1671 @end ignore |