comparison lispref/nonascii.texi @ 54036:9706b0221102

(Translation of Characters): Give examples of use. Explain about translation-table-for-input and set-buffer-file-coding-system. Minor typo fix.
author Richard M. Stallman <rms@gnu.org>
date Tue, 17 Feb 2004 01:04:35 +0000
parents 3addbe38d8a6
children ac9848689bc2
comparison
equal deleted inserted replaced
54035:5089d03a2061 54036:9706b0221102
15 * Text Representations:: Unibyte and multibyte representations 15 * Text Representations:: Unibyte and multibyte representations
16 * Converting Representations:: Converting unibyte to multibyte and vice versa. 16 * Converting Representations:: Converting unibyte to multibyte and vice versa.
17 * Selecting a Representation:: Treating a byte sequence as unibyte or multi. 17 * Selecting a Representation:: Treating a byte sequence as unibyte or multi.
18 * Character Codes:: How unibyte and multibyte relate to 18 * Character Codes:: How unibyte and multibyte relate to
19 codes of individual characters. 19 codes of individual characters.
20 * Character Sets:: The space of possible characters codes 20 * Character Sets:: The space of possible character codes
21 is divided into various character sets. 21 is divided into various character sets.
22 * Chars and Bytes:: More information about multibyte encodings. 22 * Chars and Bytes:: More information about multibyte encodings.
23 * Splitting Characters:: Converting a character to its byte sequence. 23 * Splitting Characters:: Converting a character to its byte sequence.
24 * Scanning Charsets:: Which character sets are used in a buffer? 24 * Scanning Charsets:: Which character sets are used in a buffer?
25 * Translation of Characters:: Translation tables are used for conversion. 25 * Translation of Characters:: Translation tables are used for conversion.
501 of characters into characters. These tables are used in encoding and 501 of characters into characters. These tables are used in encoding and
502 decoding, and for other purposes. Some coding systems specify their 502 decoding, and for other purposes. Some coding systems specify their
503 own particular translation tables; there are also default translation 503 own particular translation tables; there are also default translation
504 tables which apply to all other coding systems. 504 tables which apply to all other coding systems.
505 505
506 For instance, the coding-system @code{utf-8} has a translation table
507 that maps characters of various charsets (e.g.,
508 @code{latin-iso8859-@var{x}}) into Unicode character sets. This way,
509 it can encode Latin-2 characters into UTF-8. Meanwhile,
510 @code{unify-8859-on-decoding-mode} operates by specifying
511 @code{standard-translation-table-for-decode} to translate
512 Latin-@var{x} characters into corresponding Unicode characters.
513
506 @defun make-translation-table &rest translations 514 @defun make-translation-table &rest translations
507 This function returns a translation table based on the argument 515 This function returns a translation table based on the argument
508 @var{translations}. Each element of @var{translations} should be a 516 @var{translations}. Each element of @var{translations} should be a
509 list of elements of the form @code{(@var{from} . @var{to})}; this says 517 list of elements of the form @code{(@var{from} . @var{to})}; this says
510 to translate the character @var{from} into @var{to}. 518 to translate the character @var{from} into @var{to}.
556 564
557 @defvar translation-table-for-input 565 @defvar translation-table-for-input
558 Self-inserting characters are translated through this translation 566 Self-inserting characters are translated through this translation
559 table before they are inserted. This variable automatically becomes 567 table before they are inserted. This variable automatically becomes
560 buffer-local when set. 568 buffer-local when set.
569
570 @code{set-buffer-file-coding-system} sets this variable so that your
571 keyboard input gets translated into the character sets that the buffer
572 is likely to contain.
561 @end defvar 573 @end defvar
562 574
563 @node Coding Systems 575 @node Coding Systems
564 @section Coding Systems 576 @section Coding Systems
565 577
1063 of the right way to use the variable: 1075 of the right way to use the variable:
1064 1076
1065 @example 1077 @example
1066 ;; @r{Read the file with no character code conversion.} 1078 ;; @r{Read the file with no character code conversion.}
1067 ;; @r{Assume @acronym{crlf} represents end-of-line.} 1079 ;; @r{Assume @acronym{crlf} represents end-of-line.}
1068 (let ((coding-system-for-write 'emacs-mule-dos)) 1080 (let ((coding-system-for-read 'emacs-mule-dos))
1069 (insert-file-contents filename)) 1081 (insert-file-contents filename))
1070 @end example 1082 @end example
1071 1083
1072 When its value is non-@code{nil}, @code{coding-system-for-read} takes 1084 When its value is non-@code{nil}, @code{coding-system-for-read} takes
1073 precedence over all other methods of specifying a coding system to use for 1085 precedence over all other methods of specifying a coding system to use for