46 |
|
|
47 |
CODING SYSTEM |
CODING SYSTEM |
48 |
|
|
49 |
Coding system is an object for a encoding mechanism that contains |
A coding system is an object for an encoding mechanism that contains |
50 |
information about how to convert byte sequence to character |
information about how to convert byte sequences to character |
51 |
sequences and vice versa. When we say "decode", it means converting |
sequences and vice versa. When we say "decode", it means converting |
52 |
a byte sequence of a specific coding system into a character |
a byte sequence of a specific coding system into a character |
53 |
sequence that is represented by Emacs' internal coding system |
sequence that is represented by Emacs' internal coding system |
57 |
|
|
58 |
In Emacs Lisp, a coding system is represented by a Lisp symbol. In |
In Emacs Lisp, a coding system is represented by a Lisp symbol. In |
59 |
C level, a coding system is represented by a vector of attributes |
C level, a coding system is represented by a vector of attributes |
60 |
stored in the hash table Vcharset_hash_table. The conversion from a |
stored in the hash table Vcharset_hash_table. The conversion from |
61 |
coding system symbol to attributes vector is done by looking up |
coding system symbol to attributes vector is done by looking up |
62 |
Vcharset_hash_table by the symbol. |
Vcharset_hash_table by the symbol. |
63 |
|
|
64 |
Coding systems are classified into the following types depending on |
Coding systems are classified into the following types depending on |
65 |
the mechanism of encoding. Here's a brief descrition about type. |
the encoding mechanism. Here's a brief description of the types. |
66 |
|
|
67 |
o UTF-8 |
o UTF-8 |
68 |
|
|
71 |
o Charset-base coding system |
o Charset-base coding system |
72 |
|
|
73 |
A coding system defined by one or more (coded) character sets. |
A coding system defined by one or more (coded) character sets. |
74 |
Decoding and encoding are done by code converter defined for each |
Decoding and encoding are done by a code converter defined for each |
75 |
character set. |
character set. |
76 |
|
|
77 |
o Old Emacs' internal format (emacs-mule) |
o Old Emacs internal format (emacs-mule) |
78 |
|
|
79 |
The coding system adopted by an old versions of Emacs (20 and 21). |
The coding system adopted by old versions of Emacs (20 and 21). |
80 |
|
|
81 |
o ISO2022-base coding system |
o ISO2022-base coding system |
82 |
|
|
101 |
|
|
102 |
o CCL |
o CCL |
103 |
|
|
104 |
If a user wants to decode/encode a text encoded in a coding system |
If a user wants to decode/encode text encoded in a coding system |
105 |
not listed above, he can supply a decoder and an encoder for it in |
not listed above, he can supply a decoder and an encoder for it in |
106 |
CCL (Code Conversion Language) programs. Emacs executes the CCL |
CCL (Code Conversion Language) programs. Emacs executes the CCL |
107 |
program while decoding/encoding. |
program while decoding/encoding. |
109 |
o Raw-text |
o Raw-text |
110 |
|
|
111 |
A coding system for a text containing raw eight-bit data. Emacs |
A coding system for a text containing raw eight-bit data. Emacs |
112 |
treat each byte of source text as a character (except for |
treats each byte of source text as a character (except for |
113 |
end-of-line conversion). |
end-of-line conversion). |
114 |
|
|
115 |
o No-conversion |
o No-conversion |
119 |
|
|
120 |
END-OF-LINE FORMAT |
END-OF-LINE FORMAT |
121 |
|
|
122 |
How end-of-line of a text is encoded depends on a system. For |
How text end-of-line is encoded depends on operating system. For |
123 |
instance, Unix's format is just one byte of LF (line-feed) code, |
instance, Unix's format is just one byte of LF (line-feed) code, |
124 |
whereas DOS's format is two-byte sequence of `carriage-return' and |
whereas DOS's format is two-byte sequence of `carriage-return' and |
125 |
`line-feed' codes. MacOS's format is usually one byte of |
`line-feed' codes. MacOS's format is usually one byte of |
126 |
`carriage-return'. |
`carriage-return'. |
127 |
|
|
128 |
Since text characters encoding and end-of-line encoding are |
Since text character encoding and end-of-line encoding are |
129 |
independent, any coding system described above can take any format |
independent, any coding system described above can take any format |
130 |
of end-of-line (except for no-conversion). |
of end-of-line (except for no-conversion). |
131 |
|
|
134 |
Before using a coding system for code conversion (i.e. decoding and |
Before using a coding system for code conversion (i.e. decoding and |
135 |
encoding), we setup a structure of type `struct coding_system'. |
encoding), we setup a structure of type `struct coding_system'. |
136 |
This structure keeps various information about a specific code |
This structure keeps various information about a specific code |
137 |
conversion (e.g. the location of source and destination data). |
conversion (e.g. the location of source and destination data). |
138 |
|
|
139 |
*/ |
*/ |
140 |
|
|
7628 |
} |
} |
7629 |
|
|
7630 |
Fputhash (alias, spec, Vcoding_system_hash_table); |
Fputhash (alias, spec, Vcoding_system_hash_table); |
7631 |
Vcoding_system_alist = Fcons (Fcons (alias, Qnil), Vcoding_system_alist); |
Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (alias), Qnil), |
7632 |
|
Vcoding_system_alist); |
7633 |
|
|
7634 |
return Qnil; |
return Qnil; |
7635 |
} |
} |