]> code.delx.au - gnu-emacs/blob - lisp/international/mule-conf.el
(select-safe-coding-system): If
[gnu-emacs] / lisp / international / mule-conf.el
1 ;;; mule-conf.el --- configure multilingual environment
2
3 ;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5
6 ;; Keywords: mule, multilingual, character set, coding system
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;; Don't byte-compile this file.
28
29 ;;; Code:
30
31 ;;; Definitions of character sets.
32
33 ;; Basic (official) character sets. These character sets are treated
34 ;; efficiently with respect to buffer memory.
35
36 ;; Syntax:
37 ;; (define-charset CHARSET-ID CHARSET
38 ;; [ DIMENSION CHARS WIDTH DIRECTION ISO-FINAL-CHAR ISO-GRAPHIC-PLANE
39 ;; SHORT-NAME LONG-NAME DESCRIPTION ])
40 ;; ASCII charset is defined in src/charset.c as below.
41 ;; (define-charset 0 ascii
42 ;; [1 94 1 0 ?B 0 "ASCII" "ASCII" "ASCII (ISO646 IRV)"])
43
44 ;; 1-byte charsets. Valid range of CHARSET-ID is 128..143.
45
46 ;; CHARSET-ID 128 is not used.
47
48 (define-charset 129 'latin-iso8859-1
49 [1 96 1 0 ?A 1 "RHP of Latin-1" "RHP of Latin-1 (ISO 8859-1): ISO-IR-100"
50 "Right-Hand Part of Latin Alphabet 1 (ISO/IEC 8859-1): ISO-IR-100"])
51 (define-charset 130 'latin-iso8859-2
52 [1 96 1 0 ?B 1 "RHP of Latin-2" "RHP of Latin-2 (ISO 8859-2): ISO-IR-101"
53 "Right-Hand Part of Latin Alphabet 2 (ISO/IEC 8859-2): ISO-IR-101"])
54 (define-charset 131 'latin-iso8859-3
55 [1 96 1 0 ?C 1 "RHP of Latin-3" "RHP of Latin-3 (ISO 8859-3): ISO-IR-109"
56 "Right-Hand Part of Latin Alphabet 3 (ISO/IEC 8859-3): ISO-IR-109"])
57 (define-charset 132 'latin-iso8859-4
58 [1 96 1 0 ?D 1 "RHP of Latin-4" "RHP of Latin-4 (ISO 8859-4): ISO-IR-110"
59 "Right-Hand Part of Latin Alphabet 4 (ISO/IEC 8859-4): ISO-IR-110"])
60 (define-charset 133 'thai-tis620
61 [1 96 1 0 ?T 1 "RHP of TIS620" "RHP of Thai (TIS620): ISO-IR-166"
62 "Right-Hand Part of TIS620.2533 (Thai): ISO-IR-166"])
63 (define-charset 134 'greek-iso8859-7
64 [1 96 1 0 ?F 1 "RHP of ISO8859/7" "RHP of Greek (ISO 8859-7): ISO-IR-126"
65 "Right-Hand Part of Latin/Greek Alphabet (ISO/IEC 8859-7): ISO-IR-126"])
66 (define-charset 135 'arabic-iso8859-6
67 [1 96 1 1 ?G 1 "RHP of ISO8859/6" "RHP of Arabic (ISO 8859-6): ISO-IR-127"
68 "Right-Hand Part of Latin/Arabic Alphabet (ISO/IEC 8859-6): ISO-IR-127"])
69 (define-charset 136 'hebrew-iso8859-8
70 [1 96 1 1 ?H 1 "RHP of ISO8859/8" "RHP of Hebrew (ISO 8859-8): ISO-IR-138"
71 "Right-Hand Part of Latin/Hebrew Alphabet (ISO/IEC 8859-8): ISO-IR-138"])
72 (define-charset 137 'katakana-jisx0201
73 [1 94 1 0 ?I 1 "JISX0201 Katakana" "Japanese Katakana (JISX0201.1976)"
74 "Katakana Part of JISX0201.1976"])
75 (define-charset 138 'latin-jisx0201
76 [1 94 1 0 ?J 0 "JISX0201 Roman" "Japanese Roman (JISX0201.1976)"
77 "Roman Part of JISX0201.1976"])
78
79 ;; CHARSET-ID is not used 139.
80
81 (define-charset 140 'cyrillic-iso8859-5
82 [1 96 1 0 ?L 1 "RHP of ISO8859/5" "RHP of Cyrillic (ISO 8859-5): ISO-IR-144"
83 "Right-Hand Part of Latin/Cyrillic Alphabet (ISO/IEC 8859-5): ISO-IR-144"])
84 (define-charset 141 'latin-iso8859-9
85 [1 96 1 0 ?M 1 "RHP of Latin-5" "RHP of Latin-5 (ISO 8859-9): ISO-IR-148"
86 "Right-Hand Part of Latin Alphabet 5 (ISO/IEC 8859-9): ISO-IR-148"])
87 (define-charset 142 'latin-iso8859-15
88 [1 96 1 0 ?b 1 "RHP of Latin-9" "RHP of Latin-9 (ISO 8859-15): ISO-IR-203"
89 "Right-Hand Part of Latin Alphabet 9 (ISO/IEC 8859-15): ISO-IR-203"])
90 (define-charset 143 'latin-iso8859-14
91 [1 96 1 0 ?_ 1 "RHP of Latin-8" "RHP of Latin-8 (ISO 8859-14)"
92 "Right-Hand Part of Latin Alphabet 8 (ISO/IEC 8859-14)"])
93
94 ;; 2-byte charsets. Valid range of CHARSET-ID is 144..153.
95
96 (define-charset 144 'japanese-jisx0208-1978
97 [2 94 2 0 ?@ 0 "JISX0208.1978" "JISX0208.1978 (Japanese): ISO-IR-42"
98 "JISX0208.1978 Japanese Kanji (so called \"old JIS\"): ISO-IR-42"])
99 (define-charset 145 'chinese-gb2312
100 [2 94 2 0 ?A 0 "GB2312" "GB2312: ISO-IR-58"
101 "GB2312 Chinese simplified: ISO-IR-58"])
102 (define-charset 146 'japanese-jisx0208
103 [2 94 2 0 ?B 0 "JISX0208" "JISX0208.1983/1990 (Japanese): ISO-IR-87"
104 "JISX0208.1983/1990 Japanese Kanji: ISO-IR-87"])
105 (define-charset 147 'korean-ksc5601
106 [2 94 2 0 ?C 0 "KSC5601" "KSC5601 (Korean): ISO-IR-149"
107 "KSC5601 Korean Hangul and Hanja: ISO-IR-149"])
108 (define-charset 148 'japanese-jisx0212
109 [2 94 2 0 ?D 0 "JISX0212" "JISX0212 (Japanese): ISO-IR-159"
110 "JISX0212 Japanese supplement: ISO-IR-159"])
111 (define-charset 149 'chinese-cns11643-1
112 [2 94 2 0 ?G 0 "CNS11643-1" "CNS11643-1 (Chinese traditional): ISO-IR-171"
113 "CNS11643 Plane 1 Chinese traditional: ISO-IR-171"])
114 (define-charset 150 'chinese-cns11643-2
115 [2 94 2 0 ?H 0 "CNS11643-2" "CNS11643-2 (Chinese traditional): ISO-IR-172"
116 "CNS11643 Plane 2 Chinese traditional: ISO-IR-172"])
117 (define-charset 151 'japanese-jisx0213-1
118 [2 94 2 0 ?O 0 "JISX0213-1" "JISX0213-1" "JISX0213 Plane 1 (Japanese)"])
119 (define-charset 152 'chinese-big5-1
120 [2 94 2 0 ?0 0 "Big5 (Level-1)" "Big5 (Level-1) A141-C67F"
121 "Frequentry used part (A141-C67F) of Big5 (Chinese traditional)"])
122 (define-charset 153 'chinese-big5-2
123 [2 94 2 0 ?1 0 "Big5 (Level-2)" "Big5 (Level-2) C940-FEFE"
124 "Less frequentry used part (C940-FEFE) of Big5 (Chinese traditional)"])
125
126 ;; Additional (private) character sets. These character sets are
127 ;; treated less space-efficiently in the buffer.
128
129 ;; Syntax:
130 ;; (define-charset CHARSET-ID CHARSET
131 ;; [ DIMENSION CHARS WIDTH DIRECTION ISO-FINAL-CHAR ISO-GRAPHIC-PLANE
132 ;; SHORT-NAME LONG-NAME DESCRIPTION ])
133
134 ;; ISO-2022 allows a use of character sets not registered in ISO with
135 ;; final characters `0' (0x30) through `?' (0x3F). Among them, Emacs
136 ;; reserves `0' through `9' to support several private character sets.
137 ;; The remaining final characters `:' through `?' are for users.
138
139 ;; 1-byte 1-column charsets. Valid range of CHARSET-ID is 160..223.
140
141 (define-charset 160 'chinese-sisheng
142 [1 94 1 0 ?0 0 "SiSheng" "SiSheng (PinYin/ZhuYin)"
143 "SiSheng characters for PinYin/ZhuYin"])
144
145 ;; IPA characters for phonetic symbols.
146 (define-charset 161 'ipa
147 [1 96 1 0 ?0 1 "IPA" "IPA" "IPA (International Phonetic Association)"])
148
149 ;; Vietnamese VISCII. VISCII is 1-byte character set which contains
150 ;; more than 96 characters. Since Emacs can't handle it as one
151 ;; character set, it is divided into two: lower case letters and upper
152 ;; case letters.
153 (define-charset 162 'vietnamese-viscii-lower
154 [1 96 1 0 ?1 1 "VISCII lower" "VISCII lower-case" "VISCII1.1 lower-case"])
155 (define-charset 163 'vietnamese-viscii-upper
156 [1 96 1 0 ?2 1 "VISCII upper" "VISCII upper-case" "VISCII1.1 upper-case"])
157
158 ;; For Arabic, we need three different types of character sets.
159 ;; Digits are of direction left-to-right and of width 1-column.
160 ;; Others are of direction right-to-left and of width 1-column or
161 ;; 2-column.
162 (define-charset 164 'arabic-digit
163 [1 94 1 0 ?2 0 "Arabic digit" "Arabic digit" "Arabic digit"])
164 (define-charset 165 'arabic-1-column
165 [1 94 1 1 ?3 0 "Arabic 1-col" "Arabic 1-column" "Arabic 1-column"])
166
167 ;; ASCII with right-to-left direction.
168 (define-charset 166 'ascii-right-to-left
169 [1 94 1 1 ?B 0 "rev ASCII" "ASCII with right-to-left direction"
170 "ASCII (left half of ISO 8859-1) with right-to-left direction"])
171
172 ;; Lao script.
173 ;; ISO10646's 0x0E80..0x0EDF are mapped to 0x20..0x7F.
174 (define-charset 167 'lao
175 [1 94 1 0 ?1 0 "Lao" "Lao" "Lao characters (ISO10646 0E80..0EDF)"])
176
177 ;; CHARSET-IDs 168..223 are not used.
178
179 ;; 1-byte 2-column charsets. Valid range of CHARSET-ID is 224..239.
180
181 (define-charset 224 'arabic-2-column
182 [1 94 2 1 ?4 0 "Arabic 2-col" "Arabic 2-column" "Arabic 2-column"])
183
184 ;; Indian scripts. Symbolic charset for data exchange. Glyphs are
185 ;; not assigned. They are automatically converted to each Indian
186 ;; script which IS-13194 supports.
187
188 (define-charset 225 'indian-is13194
189 [1 94 2 0 ?5 1 "IS 13194" "Indian IS 13194"
190 "Generic Indian charset for data exchange with IS 13194"])
191
192 ;; CHARSET-IDs 226..239 are not used.
193
194 ;; 2-byte 1-column charsets. Valid range of CHARSET-ID is 240..244.
195
196 ;; Actual Glyph for 1-column width.
197 (define-charset 240 'indian-1-column
198 [2 94 1 0 ?6 0 "Indian 1-col" "Indian 1 Column"
199 "Indian charset for 2-column width glyphs"])
200
201 (define-charset 241 'tibetan-1-column
202 [2 94 1 0 ?8 0 "Tibetan 1-col" "Tibetan 1 column" "Tibetan 1 column glyph"])
203
204 ;; CHARSET-IDs 242 and 243 are not used.
205
206 ;; Subset of Unicode.
207 (define-charset 244 'mule-unicode-0100-24ff
208 [2 96 1 0 ?1 0 "Unicode subset" "Unicode subset (U+0100..U+24FF)"
209 "Unicode characters of the range U+0100..U+24FF."])
210
211 ;; 2-byte 2-column charsets. Valid range of CHARSET-ID is 245..254.
212
213 ;; Ethiopic characters (Amahric and Tigrigna).
214 (define-charset 245 'ethiopic
215 [2 94 2 0 ?3 0 "Ethiopic" "Ethiopic characters" "Ethiopic characters"])
216
217 ;; Chinese CNS11643 Plane3 thru Plane7. Although these are official
218 ;; character sets, the use is rare and don't have to be treated
219 ;; space-efficiently in the buffer.
220 (define-charset 246 'chinese-cns11643-3
221 [2 94 2 0 ?I 0 "CNS11643-3" "CNS11643-3 (Chinese traditional): ISO-IR-183"
222 "CNS11643 Plane 3 Chinese Traditional: ISO-IR-183"])
223 (define-charset 247 'chinese-cns11643-4
224 [2 94 2 0 ?J 0 "CNS11643-4" "CNS11643-4 (Chinese traditional): ISO-IR-184"
225 "CNS11643 Plane 4 Chinese Traditional: ISO-IR-184"])
226 (define-charset 248 'chinese-cns11643-5
227 [2 94 2 0 ?K 0 "CNS11643-5" "CNS11643-5 (Chinese traditional): ISO-IR-185"
228 "CNS11643 Plane 5 Chinese Traditional: ISO-IR-185"])
229 (define-charset 249 'chinese-cns11643-6
230 [2 94 2 0 ?L 0 "CNS11643-6" "CNS11643-6 (Chinese traditional): ISO-IR-186"
231 "CNS11643 Plane 6 Chinese Traditional: ISO-IR-186"])
232 (define-charset 250 'chinese-cns11643-7
233 [2 94 2 0 ?M 0 "CNS11643-7" "CNS11643-7 (Chinese traditional): ISO-IR-187"
234 "CNS11643 Plane 7 Chinese Traditional: ISO-IR-187"])
235
236 ;; Actual Glyph for 2-column width.
237 (define-charset 251 'indian-2-column
238 [2 94 2 0 ?5 0 "Indian 2-col" "Indian 2 Column"
239 "Indian charset for 2-column width glyphs"])
240
241 ;; Tibetan script.
242 (define-charset 252 'tibetan
243 [2 94 2 0 ?7 0 "Tibetan 2-col" "Tibetan 2 column" "Tibetan characters"])
244
245 ;; CHARSET-ID 253 is not used.
246
247 ;; JISX0213 Plane 2
248 (define-charset 254 'japanese-jisx0213-2
249 [2 94 2 0 ?P 0 "JISX0213-2" "JISX0213-2" "JISX0213 Plane 2 (Japanese)"])
250
251 ;; Tell C code charset ID's of several charsets.
252 (setup-special-charsets)
253
254 \f
255 ;; These are tables for translating characters on decoding and
256 ;; encoding.
257 (define-translation-table
258 'oldjis-newjis-jisroman-ascii
259 (list (cons (make-char 'japanese-jisx0208-1978)
260 (make-char 'japanese-jisx0208))
261 (cons (make-char 'latin-jisx0201) (make-char 'ascii))))
262
263 (setq standard-translation-table-for-decode
264 (get 'oldjis-newjis-jisroman-ascii 'translation-table))
265
266 (setq standard-translation-table-for-encode nil)
267
268 \f
269 ;;; Make fundamental coding systems.
270
271 ;; Miscellaneous coding systems which can't be made by
272 ;; `make-coding-system'.
273
274 (put 'no-conversion 'coding-system
275 (vector nil ?= "Do no conversion"
276 (list 'coding-category 'coding-category-binary
277 'alias-coding-systems '(no-conversion))
278 nil))
279 (put 'no-conversion 'eol-type 0)
280 (put 'coding-category-binary 'coding-systems '(no-conversion))
281 (setq coding-system-list '(no-conversion))
282 (setq coding-system-alist '(("no-conversion")))
283
284 (define-coding-system-alias 'binary 'no-conversion)
285
286 (put 'undecided 'coding-system
287 (vector t ?- "No conversion on encoding, automatic conversion on decoding"
288 (list 'alias-coding-systems '(undecided)
289 'safe-charsets '(ascii))
290 nil))
291 (setq coding-system-list (cons 'undecided coding-system-list))
292 (setq coding-system-alist (cons '("undecided") coding-system-alist))
293 (put 'undecided 'eol-type
294 (make-subsidiary-coding-system 'undecided))
295
296 (define-coding-system-alias 'dos 'undecided-dos)
297 (define-coding-system-alias 'mac 'undecided-mac)
298
299 ;; Coding systems not specific to each language environment.
300
301 (make-coding-system
302 'emacs-mule 0 ?=
303 "Emacs internal format used in buffer and string"
304 nil
305 '((safe-charsets . t)))
306
307 (make-coding-system
308 'raw-text 5 ?t
309 "Raw text, which means text contains random 8-bit codes."
310 nil
311 '((safe-charsets . t)))
312
313 (make-coding-system
314 'iso-2022-7bit 2 ?J
315 "ISO 2022 based 7-bit encoding using only G0"
316 '((ascii t) nil nil nil
317 short ascii-eol ascii-cntl seven)
318 '((safe-charsets . t)
319 (composition . t)))
320
321 (make-coding-system
322 'iso-2022-7bit-ss2 2 ?$
323 "ISO 2022 based 7-bit encoding using SS2 for 96-charset"
324 '((ascii t) nil t nil
325 short ascii-eol ascii-cntl seven nil single-shift)
326 '((safe-charsets . t)
327 (composition . t)))
328
329 (make-coding-system
330 'iso-2022-7bit-lock 2 ?&
331 "ISO-2022 coding system using Locking-Shift for 96-charset"
332 '((ascii t) t nil nil
333 nil ascii-eol ascii-cntl seven locking-shift)
334 '((safe-charsets . t)
335 (composition . t)))
336
337 (define-coding-system-alias 'iso-2022-int-1 'iso-2022-7bit-lock)
338
339 (make-coding-system
340 'iso-2022-7bit-lock-ss2 2 ?i
341 "Mixture of ISO-2022-JP, ISO-2022-KR, and ISO-2022-CN"
342 '((ascii t)
343 (nil korean-ksc5601 chinese-gb2312 chinese-cns11643-1 t)
344 (nil chinese-cns11643-2)
345 (nil chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5
346 chinese-cns11643-6 chinese-cns11643-7)
347 short ascii-eol ascii-cntl seven locking-shift single-shift nil nil nil
348 init-bol)
349 '((safe-charsets ascii japanese-jisx0208 japanese-jisx0208-1978 latin-jisx0201
350 korean-ksc5601 chinese-gb2312 chinese-cns11643-1
351 chinese-cns11643-2 chinese-cns11643-3 chinese-cns11643-4
352 chinese-cns11643-5 chinese-cns11643-6 chinese-cns11643-7)
353 (composition . t)))
354
355 (define-coding-system-alias 'iso-2022-cjk 'iso-2022-7bit-lock-ss2)
356
357 (make-coding-system
358 'iso-2022-8bit-ss2 2 ?@
359 "ISO 2022 based 8-bit encoding using SS2 for 96-charset"
360 '((ascii t) nil t nil
361 nil ascii-eol ascii-cntl nil nil single-shift)
362 '((safe-charsets . t)
363 (composition . t)))
364
365 (make-coding-system
366 'x-ctext 2 ?x
367 "Compound text based generic encoding for decoding unknown messages."
368 '((ascii t) (latin-iso8859-1 t) t t
369 nil ascii-eol ascii-cntl nil locking-shift single-shift nil nil nil
370 init-bol nil nil)
371 '((safe-charsets . t)
372 (mime-charset . x-ctext)
373 (composition . t)))
374
375 (make-coding-system
376 'iso-safe 2 ?-
377 "Convert all characters but ASCII to `?'."
378 '(ascii nil nil nil
379 nil ascii-eol ascii-cntl nil nil nil nil nil nil nil nil t)
380 '((safe-charsets ascii)))
381
382 ;; Use iso-safe for terminal output if some other coding system is not
383 ;; specified explicitly.
384 (set-safe-terminal-coding-system-internal 'iso-safe)
385
386 ;; The other coding-systems are defined in each language specific
387 ;; section of languages.el.
388
389 ;; Normally, set coding system to `undecided' before reading a file.
390 ;; Compiled Emacs Lisp files (*.elc) are not decoded at all,
391 ;; but we regard them as containing multibyte characters.
392 ;; Tar files are not decoded at all, but we treat them as raw bytes.
393
394 (setq file-coding-system-alist
395 '(("\\.elc$" . (emacs-mule . emacs-mule))
396 ("\\(\\`\\|/\\)loaddefs.el$" . (no-conversion . no-conversion))
397 ("\\.tar$" . (no-conversion . no-conversion))
398 ("" . (undecided . nil))))
399
400 \f
401 ;;; Setting coding categories and their priorities.
402
403 ;; This setting is just to read an Emacs Lisp source files which
404 ;; contain multilingual text while dumping Emacs. More appropriate
405 ;; values are set by the command `set-language-environment' for each
406 ;; language environment.
407
408 (setq coding-category-emacs-mule 'emacs-mule
409 coding-category-sjis 'japanese-shift-jis
410 coding-category-iso-7 'iso-2022-7bit
411 coding-category-iso-7-tight 'iso-2022-jp
412 coding-category-iso-8-1 'iso-latin-1
413 coding-category-iso-8-2 'iso-latin-1
414 coding-category-iso-7-else 'iso-2022-7bit-lock
415 coding-category-iso-8-else 'iso-2022-8bit-ss2
416 coding-category-ccl nil
417 coding-category-utf-8 nil
418 coding-category-utf-16-be nil
419 coding-category-utf-16-le nil
420 coding-category-big5 'chinese-big5
421 coding-category-raw-text 'raw-text
422 coding-category-binary 'no-conversion)
423
424 (set-coding-priority
425 '(coding-category-iso-8-1
426 coding-category-iso-8-2
427 coding-category-iso-7-tight
428 coding-category-iso-7
429 coding-category-iso-7-else
430 coding-category-iso-8-else
431 coding-category-emacs-mule
432 coding-category-raw-text
433 coding-category-sjis
434 coding-category-big5
435 coding-category-ccl
436 coding-category-binary
437 coding-category-utf-16-be
438 coding-category-utf-16-le
439 coding-category-utf-8))
440
441 \f
442 ;;; Miscellaneous settings.
443 (aset latin-extra-code-table ?\222 t)
444
445 (update-coding-systems-internal)
446
447 ;;; mule-conf.el ends here