@c This is part of the Emacs manual.
@c Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004,
-@c 2005, 2006 Free Software Foundation, Inc.
+@c 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node International, Major Modes, Frames, Top
@chapter International Character Set Support
* Coding Systems:: Character set conversion when you read and
write files, and so on.
* Recognize Coding:: How Emacs figures out which conversion to use.
+* Specify Coding:: Specifying a file's coding system explicitly.
+* Output Coding:: Choosing coding systems for output.
* Text Coding:: Choosing conversion to use for file text.
* Communication Coding:: Coding systems for interprocess communication.
* File Name Coding:: Coding systems for file @emph{names}.
load a Lisp file as unibyte, on any one occasion, by typing @kbd{C-x
@key{RET} c raw-text @key{RET}} immediately before loading it.
- The mode line indicates whether multibyte character support is enabled
-in the current buffer. If it is, there are two or more characters (most
-often two dashes) before the colon near the beginning of the mode line.
-When multibyte characters are not enabled, nothing precedes the colon
-except a single dash.
+ The mode line indicates whether multibyte character support is
+enabled in the current buffer. If it is, there are two or more
+characters (most often two dashes) near the beginning of the mode
+line, before the indication of the visited file's end-of-line
+convention (colon, backslash, etc.). When multibyte characters
+are not enabled, nothing precedes the colon except a single dash.
+@xref{Mode Line}, for more details about this.
@node Language Environments
@section Language Environments
@cindex Euro sign
@cindex UTF-8
@quotation
-Belarusian, Brazilian Portuguese, Bulgarian, Chinese-BIG5,
+ASCII, Belarusian, Brazilian Portuguese, Bulgarian, Chinese-BIG5,
Chinese-CNS, Chinese-EUC-TW, Chinese-GB, Croatian, Cyrillic-ALT,
Cyrillic-ISO, Cyrillic-KOI8, Czech, Devanagari, Dutch, English,
-Ethiopic, French, Georgian, German, Greek, Hebrew, IPA, Italian,
-Japanese, Kannada, Korean, Lao, Latin-1, Latin-2, Latin-3,
-Latin-4, Latin-5, Latin-6, Latin-7, Latin-8 (Celtic),
-Latin-9 (updated Latin-1 with the Euro sign), Latvian,
-Lithuanian, Malayalam, Polish, Romanian, Russian, Slovak,
-Slovenian, Spanish, Swedish, Tajik, Tamil, Thai, Tibetan,
-Turkish, UTF-8 (for a setup which prefers Unicode characters and
-files encoded in UTF-8), Ukrainian, Vietnamese, Welsh, and
-Windows-1255 (for a setup which prefers Cyrillic characters and
+Esperanto, Ethiopic, French, Georgian, German, Greek, Hebrew, IPA,
+Italian, Japanese, Kannada, Korean, Lao, Latin-1, Latin-2, Latin-3,
+Latin-4, Latin-5, Latin-6, Latin-7, Latin-8 (Celtic), Latin-9 (updated
+Latin-1 with the Euro sign), Latvian, Lithuanian, Malayalam, Polish,
+Romanian, Russian, Slovak, Slovenian, Spanish, Swedish, Tajik, Tamil,
+Thai, Tibetan, Turkish, UTF-8 (for a setup which prefers Unicode
+characters and files encoded in UTF-8), Ukrainian, Vietnamese, Welsh,
+and Windows-1255 (for a setup which prefers Cyrillic characters and
files encoded in Windows-1255).
+@tex
+\hbadness=10000\par % just avoid underfull hbox warning
+@end tex
@end quotation
@cindex fonts for various scripts
character.
@findex list-input-methods
- To display a list of all the supported input methods, type @kbd{M-x
+ To see a list of all the supported input methods, type @kbd{M-x
list-input-methods}. The list gives information about each input
method, including the string that stands for it in the mode line.
@key{RET}}@footnote{
In the MS-DOS port of Emacs, you need to create a @code{cp@var{nnn}}
coding system with @kbd{M-x codepage-setup}, before you can use it.
-@xref{MS-DOS and MULE,,,emacs-extra,Specialized Emacs Features}.}.
+@iftex
+@xref{MS-DOS and MULE,,,emacs-extra,Specialized Emacs Features}.
+@end iftex
+@ifnottex
+@xref{MS-DOS and MULE}.
+@end ifnottex
+}.
In addition to converting various representations of non-@acronym{ASCII}
characters, a coding system can perform end-of-line conversion. Emacs
variants @code{iso-latin-1-unix}, @code{iso-latin-1-dos} and
@code{iso-latin-1-mac}.
+@cindex @code{undecided}, coding system
+ The coding systems @code{unix}, @code{dos}, and @code{mac} are
+aliases for @code{undecided-unix}, @code{undecided-dos}, and
+@code{undecided-mac}, respectively. These coding systems specify only
+the end-of-line conversion, and leave the character code conversion to
+be deduced from the text itself.
+
The coding system @code{raw-text} is good for a file which is mainly
@acronym{ASCII} text, but may contain byte values above 127 which are
not meant to encode non-@acronym{ASCII} characters. With
handles end-of-line conversion based on the data encountered, and has
the usual three variants to specify the kind of end-of-line conversion.
+@findex unify-8859-on-decoding-mode
+@anchor{Character Translation}
+ The @dfn{character translation} feature can modify the effect of
+various coding systems, by changing the internal Emacs codes that
+decoding produces. For instance, the command
+@code{unify-8859-on-decoding-mode} enables a mode that ``unifies'' the
+Latin alphabets when decoding text. This works by converting all
+non-@acronym{ASCII} Latin-@var{n} characters to either Latin-1 or
+Unicode characters. This way it is easier to use various
+Latin-@var{n} alphabets together. (In a future Emacs version we hope
+to move towards full Unicode support and complete unification of
+character sets.)
+
+@vindex enable-character-translation
+ If you set the variable @code{enable-character-translation} to
+@code{nil}, that disables all character translation (including
+@code{unify-8859-on-decoding-mode}).
+
@node Recognize Coding
@section Recognizing Coding Systems
correspondence. There is a special function
@code{modify-coding-system-alist} for adding elements to this list. For
example, to read and write all @samp{.txt} files using the coding system
-@code{china-iso-8bit}, you can execute this Lisp expression:
+@code{chinese-iso-8bit}, you can execute this Lisp expression:
@smallexample
(modify-coding-system-alist 'file "\\.txt\\'" 'chinese-iso-8bit)
decoded correctly when you visit those files if you suppress the
escape sequence detection.
-@vindex coding
- You can specify the coding system for a particular file using the
-@w{@samp{-*-@dots{}-*-}} construct at the beginning of a file, or a
-local variables list at the end (@pxref{File Variables}). You do this
-by defining a value for the ``variable'' named @code{coding}. Emacs
-does not really have a variable @code{coding}; instead of setting a
-variable, this uses the specified coding system for the file. For
-example, @samp{-*-mode: C; coding: latin-1;-*-} specifies use of the
-Latin-1 coding system, as well as C mode. When you specify the coding
-explicitly in the file, that overrides
-@code{file-coding-system-alist}.
-
@vindex auto-coding-alist
@vindex auto-coding-regexp-alist
@vindex auto-coding-functions
pattern, are decoded correctly. One of the builtin
@code{auto-coding-functions} detects the encoding for XML files.
+@vindex rmail-decode-mime-charset
+ When you get new mail in Rmail, each message is translated
+automatically from the coding system it is written in, as if it were a
+separate file. This uses the priority list of coding systems that you
+have specified. If a MIME message specifies a character set, Rmail
+obeys that specification, unless @code{rmail-decode-mime-charset} is
+@code{nil}.
+
+@vindex rmail-file-coding-system
+ For reading and saving Rmail files themselves, Emacs uses the coding
+system specified by the variable @code{rmail-file-coding-system}. The
+default value is @code{nil}, which means that Rmail files are not
+translated (they are read and written in the Emacs internal character
+code).
+
+@node Specify Coding
+@section Specifying a File's Coding System
+
If Emacs recognizes the encoding of a file incorrectly, you can
reread the file using the correct coding system by typing @kbd{C-x
@key{RET} r @var{coding-system} @key{RET}}. To see what coding system
mnemonic letter near the left edge of the mode line (@pxref{Mode
Line}), or type @kbd{C-h C @key{RET}}.
-@findex unify-8859-on-decoding-mode
- The command @code{unify-8859-on-decoding-mode} enables a mode that
-``unifies'' the Latin alphabets when decoding text. This works by
-converting all non-@acronym{ASCII} Latin-@var{n} characters to either
-Latin-1 or Unicode characters. This way it is easier to use various
-Latin-@var{n} alphabets together. In a future Emacs version we hope
-to move towards full Unicode support and complete unification of
-character sets.
+@vindex coding
+ You can specify the coding system for a particular file in the file
+itself, using the @w{@samp{-*-@dots{}-*-}} construct at the beginning,
+or a local variables list at the end (@pxref{File Variables}). You do
+this by defining a value for the ``variable'' named @code{coding}.
+Emacs does not really have a variable @code{coding}; instead of
+setting a variable, this uses the specified coding system for the
+file. For example, @samp{-*-mode: C; coding: latin-1;-*-} specifies
+use of the Latin-1 coding system, as well as C mode. When you specify
+the coding explicitly in the file, that overrides
+@code{file-coding-system-alist}.
+
+ If you add the character @samp{!} at the end of the coding system
+name in @code{coding}, it disables any character translation
+(@pxref{Character Translation}) while decoding the file. This is
+useful when you need to make sure that the character codes in the
+Emacs buffer will not vary due to changes in user settings; for
+instance, for the sake of strings in Emacs Lisp source files.
+
+@node Output Coding
+@section Choosing Coding Systems for Output
@vindex buffer-file-coding-system
Once Emacs has chosen a coding system for a buffer, it stores that
-coding system in @code{buffer-file-coding-system} and uses that coding
-system, by default, for operations that write from this buffer into a
-file. This includes the commands @code{save-buffer} and
-@code{write-region}. If you want to write files from this buffer using
-a different coding system, you can specify a different coding system for
-the buffer using @code{set-buffer-file-coding-system} (@pxref{Text
-Coding}).
-
- You can insert any possible character into any Emacs buffer, but
-most coding systems can only handle some of the possible characters.
-This means that it is possible for you to insert characters that
-cannot be encoded with the coding system that will be used to save the
-buffer. For example, you could start with an @acronym{ASCII} file and insert a
-few Latin-1 characters into it, or you could edit a text file in
-Polish encoded in @code{iso-8859-2} and add some Russian words to it.
-When you save the buffer, Emacs cannot use the current value of
+coding system in @code{buffer-file-coding-system}. That makes it the
+default for operations that write from this buffer into a file, such
+as @code{save-buffer} and @code{write-region}. You can specify a
+different coding system for further file output from the buffer using
+@code{set-buffer-file-coding-system} (@pxref{Text Coding}).
+
+ You can insert any character Emacs supports into any Emacs buffer,
+but most coding systems can only handle a subset of these characters.
+Therefore, you can insert characters that cannot be encoded with the
+coding system that will be used to save the buffer. For example, you
+could start with an @acronym{ASCII} file and insert a few Latin-1
+characters into it, or you could edit a text file in Polish encoded in
+@code{iso-8859-2} and add some Russian words to it. When you save
+that buffer, Emacs cannot use the current value of
@code{buffer-file-coding-system}, because the characters you added
cannot be encoded by that coding system.
If you insert the unsuitable characters in a mail message, Emacs
behaves a bit differently. It additionally checks whether the
most-preferred coding system is recommended for use in MIME messages;
-if not, Emacs tells you that the most-preferred coding system is
-not recommended and prompts you for another coding system. This is so
-you won't inadvertently send a message encoded in a way that your
-recipient's mail software will have difficulty decoding. (If you do
-want to use the most-preferred coding system, you can still type its
-name in response to the question.)
+if not, Emacs tells you that the most-preferred coding system is not
+recommended and prompts you for another coding system. This is so you
+won't inadvertently send a message encoded in a way that your
+recipient's mail software will have difficulty decoding. (You can
+still use an unsuitable coding system if you type its name in response
+to the question.)
@vindex sendmail-coding-system
When you send a message with Mail mode (@pxref{Sending Mail}), Emacs has
if that is non-@code{nil}. If all of these three values are @code{nil},
Emacs encodes outgoing mail using the Latin-1 coding system.
-@vindex rmail-decode-mime-charset
- When you get new mail in Rmail, each message is translated
-automatically from the coding system it is written in, as if it were a
-separate file. This uses the priority list of coding systems that you
-have specified. If a MIME message specifies a character set, Rmail
-obeys that specification, unless @code{rmail-decode-mime-charset} is
-@code{nil}.
-
-@vindex rmail-file-coding-system
- For reading and saving Rmail files themselves, Emacs uses the coding
-system specified by the variable @code{rmail-file-coding-system}. The
-default value is @code{nil}, which means that Rmail files are not
-translated (they are read and written in the Emacs internal character
-code).
-
@node Text Coding
@section Specifying a Coding System for File Text
contains characters that the coding system cannot handle.
Other file commands affected by a specified coding system include
-@kbd{C-x C-i} and @kbd{C-x C-v}, as well as the other-window variants
+@kbd{C-x i} and @kbd{C-x C-v}, as well as the other-window variants
of @kbd{C-x C-f}. @kbd{C-x @key{RET} c} also affects commands that
start subprocesses, including @kbd{M-x shell} (@pxref{Shell}). If the
immediately following command does not use the coding system, then
specified above, whose value is nonempty is the one that determines
the text representation.)
+@vindex x-select-request-type
+ The variable @code{x-select-request-type} specifies a selection data
+type of selection to request from the X server. The default value is
+@code{nil}, which means Emacs tries @code{COMPOUND_TEXT} and
+@code{UTF8_STRING}, and uses whichever result seems more appropriate.
+You can explicitly specify the data type by setting the variable to
+one of the symbols @code{COMPOUND_TEXT}, @code{UTF8_STRING},
+@code{STRING} and @code{TEXT}.
+
@node File Name Coding
@section Coding Systems for File Names
The resource value should have this form:
@smallexample
-@var{fontpattern}, @r{[}@var{charsetname}:@var{fontname}@r{]@dots{}}
+@var{fontpattern}, @r{[}@var{charset}:@var{font}@r{]@dots{}}
@end smallexample
@noindent