]> code.delx.au - gnu-emacs/blob - lisp/language/european.el
(windows-1252): New coding system.
[gnu-emacs] / lisp / language / european.el
1 ;;; european.el --- support for European languages -*- coding: iso-2022-7bit; -*-
2
3 ;; Copyright (C) 1995, 1997, 2001 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
6
7 ;; Keywords: multilingual, European
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;; For European scripts, character sets ISO8859-1,2,3,4,9,14,15 are
29 ;; supported.
30
31 ;;; Code:
32
33 ;; Latin-1 (ISO-8859-1)
34
35 (set-language-info-alist
36 "Latin-1" '((charset iso-8859-1)
37 (coding-system iso-latin-1)
38 (coding-priority iso-latin-1)
39 (nonascii-translation . iso-8859-1)
40 (unibyte-syntax . "latin-1")
41 (unibyte-display . iso-latin-1)
42 (input-method . "latin-1-prefix")
43 (sample-text
44 . "Hello, Hej, Tere, Hei, Bonjour, Gr\e,A|_\e(B Gott, Ciao, \e,A!\e(BHola!")
45 (documentation . "\
46 This language environment is a generic one for the Latin-1 (ISO-8859-1)
47 character set which supports the following European languages:
48 Albanian, Basque, Breton, Catalan, Danish, Dutch, English, Faeroese,
49 Finnish, French (with restrictions -- see Latin-9), Frisian, Galician,
50 German, Greenlandic, Icelandic, Irish Gaelic (new orthography),
51 Italian, Latin, Luxemburgish, Norwegian, Portuguese, Rhaeto-Romanic,
52 Scottish Gaelic, Spanish, and Swedish.
53 We also have specific language environments for the following languages:
54 For Dutch, \"Dutch\".
55 For German, \"German\".
56 For Spanish, \"Spanish\".
57 For French, \"French\".
58
59 Latin-1 also covers several written languages outside Europe, including
60 Indonesian/Malay, Tagalog (Philippines), Swahili and Afrikaans."))
61 '("European"))
62
63 \f
64 ;; Latin-2 (ISO-8859-2)
65
66 (define-coding-system 'iso-latin-2
67 "ISO 2022 based 8-bit encoding for Latin-2 (MIME:ISO-8859-2)."
68 :coding-type 'charset
69 :mnemonic ?2
70 :charset-list '(iso-8859-2)
71 :mime-charset 'iso-8859-2)
72
73 (define-coding-system-alias 'iso-8859-2 'iso-latin-2)
74 (define-coding-system-alias 'latin-2 'iso-latin-2)
75
76 (set-language-info-alist
77 "Latin-2" '((charset iso-8859-2)
78 (coding-system iso-latin-2)
79 (coding-priority iso-latin-2)
80 (nonascii-translation . iso-8859-2)
81 (unibyte-syntax . "latin-2")
82 (unibyte-display . iso-latin-2)
83 (input-method . "latin-2-prefix")
84 (documentation . "\
85 This language environment is a generic one for the Latin-2 (ISO-8859-2)
86 character set which supports the following languages:
87 Albanian, Czech, English, German, Hungarian, Polish, Romanian,
88 Serbo-Croatian or Croatian, Slovak, Slovene, Sorbian (upper and lower),
89 and Swedish.
90 We also have specific language environments for the following languages:
91 For Czech, \"Czech\".
92 For Romanian, \"Romanian\".
93 For Slovak, \"Slovak\"."))
94 '("European"))
95
96 \f
97 ;; Latin-3 (ISO-8859-3)
98
99 (define-coding-system 'iso-latin-3
100 "ISO 2022 based 8-bit encoding for Latin-3 (MIME:ISO-8859-3)."
101 :coding-type 'charset
102 :mnemonic ?3
103 :charset-list '(iso-8859-3)
104 :mime-charset 'iso-8859-3)
105
106 (define-coding-system-alias 'iso-8859-3 'iso-latin-3)
107 (define-coding-system-alias 'latin-3 'iso-latin-3)
108
109 (set-language-info-alist
110 "Latin-3" '((charset iso-8859-3)
111 (coding-system iso-latin-3)
112 (coding-priority iso-latin-3)
113 (nonascii-translation . iso-8859-3)
114 (unibyte-syntax . "latin-3")
115 (unibyte-display . iso-latin-3)
116 (input-method . "latin-3-prefix")
117 (documentation . "\
118 These languages are supported with the Latin-3 (ISO-8859-3) character set:
119 Afrikaans, Catalan, Dutch, English, Esperanto, French, Galician,
120 German, Italian, Maltese, Spanish, and Turkish."))
121 '("European"))
122
123 \f
124 ;; Latin-4 (ISO-8859-4)
125
126 (define-coding-system 'iso-latin-4
127 "ISO 2022 based 8-bit encoding for Latin-4 (MIME:ISO-8859-4)."
128 :coding-type 'charset
129 :mnemonic ?4
130 :charset-list '(iso-8859-4)
131 :mime-charset 'iso-8859-4)
132
133 (define-coding-system-alias 'iso-8859-4 'iso-latin-4)
134 (define-coding-system-alias 'latin-4 'iso-latin-4)
135
136 (set-language-info-alist
137 "Latin-4" '((charset iso-8859-4)
138 (coding-system iso-8859-4)
139 (coding-priority iso-8859-4)
140 (nonascii-translation . iso-8859-4)
141 (unibyte-syntax . "latin-4")
142 (unibyte-display . iso-8859-4)
143 (input-method . "latin-4-postfix")
144 (documentation . "\
145 These languages are supported with the Latin-4 (ISO-8859-4) character set:
146 Danish, English, Estonian, Finnish, German, Greenlandic, Lappish,
147 Latvian, Lithuanian, and Norwegian."))
148 '("European"))
149
150 \f
151 ;; Latin-5 (ISO-8859-9)
152
153 (define-coding-system 'iso-latin-5
154 "ISO 2022 based 8-bit encoding for Latin-5 (MIME:ISO-8859-9)."
155 :coding-type 'charset
156 :mnemonic ?9
157 :charset-list '(iso-8859-9)
158 :mime-charset 'iso-8859-9)
159
160 (define-coding-system-alias 'iso-8859-9 'iso-latin-5)
161 (define-coding-system-alias 'latin-5 'iso-latin-5)
162
163 (set-language-info-alist
164 "Latin-5" '((charset iso-8859-9)
165 (coding-system iso-latin-5)
166 (coding-priority iso-latin-5)
167 (nonascii-translation . iso-8859-9)
168 (unibyte-syntax . "latin-5")
169 (unibyte-display . iso-latin-5)
170 (input-method . "latin-5-postfix")
171 (documentation . "Support for Turkish language."))
172 '("European"))
173
174 \f
175 ;; Latin-8 (ISO-8859-14)
176
177 (define-coding-system 'iso-latin-8
178 "ISO 2022 based 8-bit encoding for Latin-8 (MIME:ISO-8859-14)."
179 :coding-type 'charset
180 ;; `W' for `Welsh', since `C' for `Celtic' is taken.
181 :mnemonic ?W
182 :charset-list '(iso-8859-14)
183 :mime-charset 'iso-8859-14)
184
185 (define-coding-system-alias 'iso-8859-14 'iso-latin-8)
186 (define-coding-system-alias 'latin-8 'iso-latin-8)
187
188 (set-language-info-alist
189 "Latin-8" '((charset iso-8859-14)
190 (coding-system iso-latin-8)
191 (coding-priority iso-latin-8)
192 (nonascii-translation . iso-8859-14)
193 (unibyte-syntax . "latin-8")
194 (unibyte-display . iso-latin-8)
195 (input-method . "latin-8-prefix")
196 ;; Fixme: Welsh/Ga{e}lic greetings
197 (sample-text . "\e,_"\e(B \e,_p\e(B \e,_^\e(B")
198 (documentation . "\
199 This language environment is a generic one for the Latin-8 (ISO-8859-14)
200 character set which supports the Celtic languages, including those not
201 covered by other ISO-8859 character sets:
202 Welsh, Manx Gaelic and Irish Gaelic (old orthography)."))
203 '("European"))
204 \f
205 ;; Latin-9 (ISO-8859-15)
206
207 (define-coding-system 'iso-latin-9
208 "ISO 2022 based 8-bit encoding for Latin-9 (MIME:ISO-8859-15)."
209 :coding-type 'charset
210 ;; `0' for `Latin-0'
211 :mnemonic ?0
212 :charset-list '(iso-8859-15)
213 :mime-charset 'iso-8859-15)
214
215 (define-coding-system-alias 'iso-8859-15 'iso-latin-9)
216 (define-coding-system-alias 'latin-9 'iso-latin-9)
217 (define-coding-system-alias 'latin-0 'iso-latin-9)
218
219 (set-language-info-alist
220 "Latin-9" '((charset iso-8859-15)
221 (coding-system iso-latin-9)
222 (coding-priority iso-latin-9)
223 (nonascii-translation . iso-8859-15)
224 (unibyte-syntax . "latin-9")
225 (unibyte-display . iso-latin-9)
226 (input-method . "latin-9-prefix")
227 (sample-text
228 . "AVE. \e,B)9.>\e,b<=\e,_/\e(B \e,b$\e(B")
229 (documentation . "\
230 This language environment is a generic one for the Latin-9 (ISO-8859-15)
231 character set which supports the same languages as Latin-1 with the
232 addition of the Euro sign and some additional French and Finnish letters.
233 Latin-9 is sometimes nicknamed `Latin-0'."))
234 '("European"))
235 \f
236 (define-coding-system 'windows-1252
237 "windows-1252 8-bit encoding for Cyrillic (MIME: WINDOWS-1252)"
238 :coding-type 'charset
239 :mnemonic ?*
240 :charset-list '(windows-1252)
241 :mime-charset 'windows-1252)
242 (define-coding-system-alias 'cp1252 'windows-1252)
243 \f
244 (set-language-info-alist
245 "German" '((tutorial . "TUTORIAL.de")
246 (charset iso-8859-1)
247 (coding-system iso-latin-1)
248 (coding-priority iso-latin-1)
249 (nonascii-translation . iso-8859-1)
250 (input-method . "german-postfix")
251 (unibyte-syntax . "latin-1")
252 (unibyte-display . iso-latin-1)
253 (sample-text . "\
254 German (Deutsch Nord) Guten Tag
255 German (Deutsch S\e,A|\e(Bd) Gr\e,A|_\e(B Gott")
256 (documentation . "\
257 This language environment is almost the same as Latin-1,
258 but sets the default input method to \"german-postfix\".
259 Additionally, it selects the German tutorial."))
260 '("European"))
261
262 (set-language-info-alist
263 "French" '((tutorial . "TUTORIAL.fr")
264 (charset iso-8859-1)
265 (coding-system iso-latin-1)
266 (coding-priority iso-latin-1)
267 (nonascii-translation . iso-8859-1)
268 (unibyte-syntax . "latin-1")
269 (unibyte-display . iso-latin-1)
270 (input-method . "latin-1-prefix")
271 (sample-text . "French (Fran\e,Ag\e(Bais) Bonjour, Salut")
272 (documentation . "\
273 This language environment is almost the same as Latin-1,
274 but it selects the French tutorial."))
275 '("European"))
276
277 (set-language-info-alist
278 "Slovenian" '((charset iso-8859-2)
279 (coding-system . (iso-8859-2))
280 (coding-priority . (iso-8859-2))
281 (nonascii-translation . iso-8859-2)
282 (input-method . "latin-2-postfix")
283 (unibyte-syntax . "latin-2")
284 (unibyte-display . iso-8859-2)
285 (tutorial . "TUTORIAL.sl")
286 (sample-text . "\e,B.\e(Belimo vam uspe\e,B9\e(Ben dan!")
287 (documentation . t))
288 '("European"))
289
290 (set-language-info-alist
291 "Spanish" '((tutorial . "TUTORIAL.es")
292 (charset iso-8859-1)
293 (coding-system iso-latin-1)
294 (coding-priority iso-latin-1)
295 (nonascii-translation . iso-8859-1)
296 (input-method . "spanish-postfix")
297 (unibyte-syntax . "latin-1")
298 (unibyte-display . iso-latin-1)
299 (sample-text . "Spanish (Espa\e,Aq\e(Bol) \e,A!\e(BHola!")
300 (documentation . "\
301 This language environment is almost the same as Latin-1,
302 but it sets the default input method to \"spanish-postfix\",
303 and it selects the Spanish tutorial."))
304 '("European"))
305
306 (set-language-info-alist
307 "Dutch" '((tutorial . "TUTORIAL.nl")
308 (charset iso-8859-1)
309 (coding-system iso-latin-1)
310 (coding-priority iso-latin-1)
311 (nonascii-translation . iso-8859-1)
312 (unibyte-syntax . "latin-1")
313 (unibyte-display . iso-latin-1)
314 (sample-text . "Er is een aantal manieren waarop je dit kan doen")
315 (documentation . "\
316 This language environment is almost the same as Latin-1,
317 but it selects the Dutch tutorial."))
318 '("European"))
319
320 ;; For Turkish, the character set ISO-8859-9 (Latin-5) is used. But,
321 ;; before the introduction of ISO-8859-9 in 1988, ISO-8859-3 (Latin-3)
322 ;; was used for Turkish. Those who use Latin-3 for Turkish should use
323 ;; "Latin-3" language environment.
324
325 (set-language-info-alist
326 "Turkish" '((charset iso-8859-9)
327 (coding-system iso-latin-5)
328 (coding-priority iso-latin-5)
329 (nonascii-translation . iso-8859-9)
330 (unibyte-syntax . "latin-5")
331 (unibyte-display . iso-latin-5)
332 (input-method . "turkish-postfix")
333 (sample-text . "Turkish (T\e,A|\e(Brk\e,Ag\e(Be) Merhaba")
334 (documentation . t)))
335
336 ;; Polish ISO 8859-2 environment.
337 ;; Maintainer: Wlodek Bzyl <matwb@univ.gda.pl>
338 ;; Keywords: multilingual, Polish
339
340 (set-language-info-alist
341 "Polish" '((charset . (iso-8859-2))
342 (coding-system . (iso-8859-2))
343 (coding-priority . (iso-8859-2))
344 (nonascii-translation . iso-8859-2)
345 (input-method . "polish-slash")
346 (unibyte-syntax . "latin-2")
347 (unibyte-display . iso-8859-2)
348 (tutorial . "TUTORIAL.pl")
349 (sample-text . "P\e,As\e(Bjd\e,B<\e(B, ki\e,Bq\e(B-\e,B?\e(Be t\e,Bj\e(B chmurno\e,B6f\e(B w g\e,B31\e(Bb flaszy")
350 (documentation . t))
351 '("European"))
352
353 (set-language-info-alist
354 "Welsh" `((coding-system utf-8 latin-8) ; the input method is Unicode-based
355 (coding-priority utf-8 latin-8)
356 (nonascii-translation . iso-8859-14)
357 (input-method . "welsh")
358 (documentation . "Support for Welsh, using Unicode."))
359 '("European"))
360
361 (set-language-info-alist
362 "Latin-7" `((coding-system latin-7)
363 (coding-priority latin-7)
364 (nonascii-translation . iso-8859-13)
365 ;; Fixme: input-method
366 (features code-pages)
367 (documentation . "Support for Latin-7, e.g. Latvian, Lithuanian."))
368 '("European"))
369
370 (set-language-info-alist
371 "Lithuanian" `((coding-system latin-7)
372 (coding-priority latin-7)
373 (nonascii-translation . iso-8859-13)
374 (input-method . "lithuanian-keyboard")
375 (features code-pages)
376 (documentation . "Support for Lithuanian."))
377 '("European"))
378
379 (set-language-info-alist
380 "Latvian" `((coding-system latin-7)
381 (coding-priority latin-7)
382 (nonascii-translation . iso-8859-13)
383 (input-method . "latvian-keyboard")
384 (features code-pages)
385 (documentation . "Support for Latvian."))
386 '("European"))
387
388 \f
389 (define-coding-system 'mac-roman
390 "Mac Roman Encoding (MIME:MACINTOSH)."
391 :coding-type 'charset
392 :mnemonic ?M
393 :charset-list '(mac-roman)
394 ;; per IANA, rfc1345
395 :mime-charset 'macintosh)
396
397 (defconst diacritic-composition-pattern "\\C^\\c^+")
398
399 (defun diacritic-compose-region (beg end)
400 "Compose diacritic characters in the region.
401 When called from a program, expects two arguments,
402 positions (integers or markers) specifying the region."
403 (interactive "r")
404 (save-restriction
405 (narrow-to-region beg end)
406 (goto-char (point-min))
407 (while (re-search-forward diacritic-composition-pattern nil t)
408 (compose-region (match-beginning 0) (match-end 0)))))
409
410 (defun diacritic-compose-string (string)
411 "Compose diacritic characters in STRING and return the resulting string."
412 (let ((idx 0))
413 (while (setq idx (string-match diacritic-composition-pattern string idx))
414 (compose-string string idx (match-end 0))
415 (setq idx (match-end 0))))
416 string)
417
418 (defun diacritic-compose-buffer ()
419 "Compose diacritic characters in the current buffer."
420 (interactive)
421 (diacritic-compose-region (point-min) (point-max)))
422
423 (defun diacritic-post-read-conversion (len)
424 (diacritic-compose-region (point) (+ (point) len))
425 len)
426
427 (defun diacritic-composition-function (from to pattern &optional string)
428 "Compose diacritic text in the region FROM and TO.
429 The text matches the regular expression PATTERN.
430 Optional 4th argument STRING, if non-nil, is a string containing text
431 to compose.
432
433 The return value is number of composed characters."
434 (if (< (1+ from) to)
435 (prog1 (- to from)
436 (if string
437 (compose-string string from to)
438 (compose-region from to))
439 (- to from))))
440
441 ;; Register a function to compose Unicode diacrtics and marks.
442 (let ((patterns '(("\\C^\\c^+" . diacritic-composition-function))))
443 (let ((c #x300))
444 (while (<= c #x362)
445 (aset composition-function-table (decode-char 'unicode c) patterns)
446 (setq c (1+ c)))
447 (setq c #x20d0)
448 (while (<= c #x20e3)
449 (aset composition-function-table (decode-char 'unicode c) patterns)
450 (setq c (1+ c)))))
451
452 (provide 'european)
453
454 ;;; european.el ends here