4 |
@c See the file elisp.texi for copying conditions. |
@c See the file elisp.texi for copying conditions. |
5 |
@setfilename ../info/characters |
@setfilename ../info/characters |
6 |
@node Non-ASCII Characters, Searching and Matching, Text, Top |
@node Non-ASCII Characters, Searching and Matching, Text, Top |
7 |
@chapter Non-@sc{ascii} Characters |
@chapter Non-@acronym{ASCII} Characters |
8 |
@cindex multibyte characters |
@cindex multibyte characters |
9 |
@cindex non-@sc{ascii} characters |
@cindex non-@acronym{ASCII} characters |
10 |
|
|
11 |
This chapter covers the special issues relating to non-@sc{ascii} |
This chapter covers the special issues relating to non-@acronym{ASCII} |
12 |
characters and how they are stored in strings and buffers. |
characters and how they are stored in strings and buffers. |
13 |
|
|
14 |
@menu |
@menu |
44 |
@cindex unibyte text |
@cindex unibyte text |
45 |
In unibyte representation, each character occupies one byte and |
In unibyte representation, each character occupies one byte and |
46 |
therefore the possible character codes range from 0 to 255. Codes 0 |
therefore the possible character codes range from 0 to 255. Codes 0 |
47 |
through 127 are @sc{ascii} characters; the codes from 128 through 255 |
through 127 are @acronym{ASCII} characters; the codes from 128 through 255 |
48 |
are used for one non-@sc{ascii} character set (you can choose which |
are used for one non-@acronym{ASCII} character set (you can choose which |
49 |
character set by setting the variable @code{nonascii-insert-offset}). |
character set by setting the variable @code{nonascii-insert-offset}). |
50 |
|
|
51 |
@cindex leading code |
@cindex leading code |
134 |
acceptable because the buffer's representation is a choice made by the |
acceptable because the buffer's representation is a choice made by the |
135 |
user that cannot be overridden automatically. |
user that cannot be overridden automatically. |
136 |
|
|
137 |
Converting unibyte text to multibyte text leaves @sc{ascii} characters |
Converting unibyte text to multibyte text leaves @acronym{ASCII} characters |
138 |
unchanged, and likewise character codes 128 through 159. It converts |
unchanged, and likewise character codes 128 through 159. It converts |
139 |
the non-@sc{ascii} codes 160 through 255 by adding the value |
the non-@acronym{ASCII} codes 160 through 255 by adding the value |
140 |
@code{nonascii-insert-offset} to each character code. By setting this |
@code{nonascii-insert-offset} to each character code. By setting this |
141 |
variable, you specify which character set the unibyte characters |
variable, you specify which character set the unibyte characters |
142 |
correspond to (@pxref{Character Sets}). For example, if |
correspond to (@pxref{Character Sets}). For example, if |
143 |
@code{nonascii-insert-offset} is 2048, which is @code{(- (make-char |
@code{nonascii-insert-offset} is 2048, which is @code{(- (make-char |
144 |
'latin-iso8859-1) 128)}, then the unibyte non-@sc{ascii} characters |
'latin-iso8859-1) 128)}, then the unibyte non-@acronym{ASCII} characters |
145 |
correspond to Latin 1. If it is 2688, which is @code{(- (make-char |
correspond to Latin 1. If it is 2688, which is @code{(- (make-char |
146 |
'greek-iso8859-7) 128)}, then they correspond to Greek letters. |
'greek-iso8859-7) 128)}, then they correspond to Greek letters. |
147 |
|
|
153 |
text. |
text. |
154 |
|
|
155 |
@defvar nonascii-insert-offset |
@defvar nonascii-insert-offset |
156 |
This variable specifies the amount to add to a non-@sc{ascii} character |
This variable specifies the amount to add to a non-@acronym{ASCII} character |
157 |
when converting unibyte text to multibyte. It also applies when |
when converting unibyte text to multibyte. It also applies when |
158 |
@code{self-insert-command} inserts a character in the unibyte |
@code{self-insert-command} inserts a character in the unibyte |
159 |
non-@sc{ascii} range, 128 through 255. However, the functions |
non-@acronym{ASCII} range, 128 through 255. However, the functions |
160 |
@code{insert} and @code{insert-char} do not perform this conversion. |
@code{insert} and @code{insert-char} do not perform this conversion. |
161 |
|
|
162 |
The right value to use to select character set @var{cs} is @code{(- |
The right value to use to select character set @var{cs} is @code{(- |
263 |
values in that range are valid. The values 128 through 255 are not |
values in that range are valid. The values 128 through 255 are not |
264 |
entirely proper in multibyte text, but they can occur if you do explicit |
entirely proper in multibyte text, but they can occur if you do explicit |
265 |
encoding and decoding (@pxref{Explicit Encoding}). Some other character |
encoding and decoding (@pxref{Explicit Encoding}). Some other character |
266 |
codes cannot occur at all in multibyte text. Only the @sc{ascii} codes |
codes cannot occur at all in multibyte text. Only the @acronym{ASCII} codes |
267 |
0 through 127 are completely legitimate in both representations. |
0 through 127 are completely legitimate in both representations. |
268 |
|
|
269 |
@defun char-valid-p charcode &optional genericp |
@defun char-valid-p charcode &optional genericp |
301 |
characters, generally known as Big 5, is divided into two Emacs |
characters, generally known as Big 5, is divided into two Emacs |
302 |
character sets, @code{chinese-big5-1} and @code{chinese-big5-2}. |
character sets, @code{chinese-big5-1} and @code{chinese-big5-2}. |
303 |
|
|
304 |
@sc{ascii} characters are in character set @code{ascii}. The |
@acronym{ASCII} characters are in character set @code{ascii}. The |
305 |
non-@sc{ascii} characters 128 through 159 are in character set |
non-@acronym{ASCII} characters 128 through 159 are in character set |
306 |
@code{eight-bit-control}, and codes 160 through 255 are in character set |
@code{eight-bit-control}, and codes 160 through 255 are in character set |
307 |
@code{eight-bit-graphic}. |
@code{eight-bit-graphic}. |
308 |
|
|
336 |
@cindex dimension (of character set) |
@cindex dimension (of character set) |
337 |
In multibyte representation, each character occupies one or more |
In multibyte representation, each character occupies one or more |
338 |
bytes. Each character set has an @dfn{introduction sequence}, which is |
bytes. Each character set has an @dfn{introduction sequence}, which is |
339 |
normally one or two bytes long. (Exception: the @sc{ascii} character |
normally one or two bytes long. (Exception: the @code{ascii} character |
340 |
set and the @sc{eight-bit-graphic} character set have a zero-length |
set and the @code{eight-bit-graphic} character set have a zero-length |
341 |
introduction sequence.) The introduction sequence is the beginning of |
introduction sequence.) The introduction sequence is the beginning of |
342 |
the byte sequence for any character in the character set. The rest of |
the byte sequence for any character in the character set. The rest of |
343 |
the character's bytes distinguish it from the other characters in the |
the character's bytes distinguish it from the other characters in the |
426 |
@result{} (latin-iso8859-1 0) |
@result{} (latin-iso8859-1 0) |
427 |
@end example |
@end example |
428 |
|
|
429 |
The character sets @sc{ascii}, @sc{eight-bit-control}, and |
The character sets @code{ascii}, @code{eight-bit-control}, and |
430 |
@sc{eight-bit-graphic} don't have corresponding generic characters. If |
@code{eight-bit-graphic} don't have corresponding generic characters. If |
431 |
@var{charset} is one of them and you don't supply @var{code1}, |
@var{charset} is one of them and you don't supply @var{code1}, |
432 |
@code{make-char} returns the character code corresponding to the |
@code{make-char} returns the character code corresponding to the |
433 |
smallest code in @var{charset}. |
smallest code in @var{charset}. |
744 |
return value is just one coding system, the one that is highest in |
return value is just one coding system, the one that is highest in |
745 |
priority. |
priority. |
746 |
|
|
747 |
If the region contains only @sc{ascii} characters, the value |
If the region contains only @acronym{ASCII} characters, the value |
748 |
is @code{undecided} or @code{(undecided)}. |
is @code{undecided} or @code{(undecided)}. |
749 |
@end defun |
@end defun |
750 |
|
|
846 |
expression that matches certain file names. The element applies to file |
expression that matches certain file names. The element applies to file |
847 |
names that match @var{pattern}. |
names that match @var{pattern}. |
848 |
|
|
849 |
The @sc{cdr} of the element, @var{coding}, should be either a coding |
The @acronym{CDR} of the element, @var{coding}, should be either a coding |
850 |
system, a cons cell containing two coding systems, or a function name (a |
system, a cons cell containing two coding systems, or a function name (a |
851 |
symbol with a function definition). If @var{coding} is a coding system, |
symbol with a function definition). If @var{coding} is a coding system, |
852 |
that coding system is used for both reading the file and writing it. If |
that coding system is used for both reading the file and writing it. If |
853 |
@var{coding} is a cons cell containing two coding systems, its @sc{car} |
@var{coding} is a cons cell containing two coding systems, its @acronym{CAR} |
854 |
specifies the coding system for decoding, and its @sc{cdr} specifies the |
specifies the coding system for decoding, and its @acronym{cdr} specifies the |
855 |
coding system for encoding. |
coding system for encoding. |
856 |
|
|
857 |
If @var{coding} is a function name, the function must return a coding |
If @var{coding} is a function name, the function must return a coding |
975 |
|
|
976 |
@example |
@example |
977 |
;; @r{Read the file with no character code conversion.} |
;; @r{Read the file with no character code conversion.} |
978 |
;; @r{Assume @sc{crlf} represents end-of-line.} |
;; @r{Assume @acronym{crlf} represents end-of-line.} |
979 |
(let ((coding-system-for-write 'emacs-mule-dos)) |
(let ((coding-system-for-write 'emacs-mule-dos)) |
980 |
(insert-file-contents filename)) |
(insert-file-contents filename)) |
981 |
@end example |
@end example |
1175 |
@section Input Methods |
@section Input Methods |
1176 |
@cindex input methods |
@cindex input methods |
1177 |
|
|
1178 |
@dfn{Input methods} provide convenient ways of entering non-@sc{ascii} |
@dfn{Input methods} provide convenient ways of entering non-@acronym{ASCII} |
1179 |
characters from the keyboard. Unlike coding systems, which translate |
characters from the keyboard. Unlike coding systems, which translate |
1180 |
non-@sc{ascii} characters to and from encodings meant to be read by |
non-@acronym{ASCII} characters to and from encodings meant to be read by |
1181 |
programs, input methods provide human-friendly commands. (@xref{Input |
programs, input methods provide human-friendly commands. (@xref{Input |
1182 |
Methods,,, emacs, The GNU Emacs Manual}, for information on how users |
Methods,,, emacs, The GNU Emacs Manual}, for information on how users |
1183 |
use input methods to enter text.) How to define input methods is not |
use input methods to enter text.) How to define input methods is not |