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