]> code.delx.au - gnu-emacs/blob - lisp/international/iso-cvt.el
d7baabb29c8773ab9fb18db6cc07a792efa5579a
[gnu-emacs] / lisp / international / iso-cvt.el
1 ;;; iso-cvt.el --- translate ISO 8859-1 from/to various encodings -*- coding: iso-latin-1 -*-
2 ;; This file was formerly called gm-lingo.el.
3
4 ;; Copyright (C) 1993, 1994, 1995, 1996, 1998, 2000, 2003, 2004
5 ;; Free Software Foundation, Inc.
6
7 ;; Author: Michael Gschwind <mike@vlsivie.tuwien.ac.at>
8 ;; Keywords: tex, iso, latin, i18n
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26
27 ;;; Commentary:
28 ;; This lisp code is a general framework for translating various
29 ;; representations of the same data.
30 ;; among other things it can be used to translate TeX, HTML, and compressed
31 ;; files to ISO 8859-1. It can also be used to translate different charsets
32 ;; such as IBM PC, Macintosh or HP Roman8.
33 ;; Note that many translations use the GNU recode tool to do the actual
34 ;; conversion. So you might want to install that tool to get the full
35 ;; benefit of iso-cvt.el
36
37 ; TO DO:
38 ; Cover more cases for translation. (There is an infinite number of ways to
39 ; represent accented characters in TeX)
40
41 ;; SEE ALSO:
42 ; If you are interested in questions related to using the ISO 8859-1
43 ; characters set (configuring emacs, Unix, etc. to use ISO), then you
44 ; can get the ISO 8859-1 FAQ via anonymous ftp from
45 ; ftp.vlsivie.tuwien.ac.at in /pub/8bit/FAQ-ISO-8859-1
46
47 ;;; Code:
48
49 (defvar iso-spanish-trans-tab
50 '(
51 ("~n" "ñ")
52 ("\([a-zA-Z]\)#" "\\1ñ")
53 ("~N" "Ñ")
54 ("\\([-a-zA-Z\"`]\\)\"u" "\\1ü")
55 ("\\([-a-zA-Z\"`]\\)\"U" "\\1Ü")
56 ("\\([-a-zA-Z]\\)'o" "\\1ó")
57 ("\\([-a-zA-Z]\\)'O" "\\Ó")
58 ("\\([-a-zA-Z]\\)'e" "\\1é")
59 ("\\([-a-zA-Z]\\)'E" "\\1É")
60 ("\\([-a-zA-Z]\\)'a" "\\1á")
61 ("\\([-a-zA-Z]\\)'A" "\\1A")
62 ("\\([-a-zA-Z]\\)'i" "\\1í")
63 ("\\([-a-zA-Z]\\)'I" "\\1Í")
64 )
65 "Spanish translation table.")
66
67 (defun iso-translate-conventions (from to trans-tab)
68 "Use the translation table TRANS-TAB to translate the current buffer."
69 (save-excursion
70 (save-restriction
71 (narrow-to-region from to)
72 (goto-char from)
73 (let ((work-tab trans-tab)
74 (buffer-read-only nil)
75 (case-fold-search nil))
76 (while work-tab
77 (save-excursion
78 (let ((trans-this (car work-tab)))
79 (while (re-search-forward (car trans-this) nil t)
80 (replace-match (car (cdr trans-this)) t nil)))
81 (setq work-tab (cdr work-tab)))))
82 (point-max))))
83
84 ;;;###autoload
85 (defun iso-spanish (from to &optional buffer)
86 "Translate net conventions for Spanish to ISO 8859-1.
87 The region between FROM and TO is translated using the table TRANS-TAB.
88 Optional arg BUFFER is ignored (for use in `format-alist')."
89 (interactive "*r")
90 (iso-translate-conventions from to iso-spanish-trans-tab))
91
92 (defvar iso-aggressive-german-trans-tab
93 '(
94 ("\"a" "ä")
95 ("\"A" "Ä")
96 ("\"o" "ö")
97 ("\"O" "Ö")
98 ("\"u" "ü")
99 ("\"U" "Ü")
100 ("\"s" "ß")
101 ("\\\\3" "ß")
102 )
103 "German translation table.
104 This table uses an aggressive translation approach and may erroneously
105 translate too much.")
106
107 (defvar iso-conservative-german-trans-tab
108 '(
109 ("\\([-a-zA-Z\"`]\\)\"a" "\\1ä")
110 ("\\([-a-zA-Z\"`]\\)\"A" "\\1Ä")
111 ("\\([-a-zA-Z\"`]\\)\"o" "\\1ö")
112 ("\\([-a-zA-Z\"`]\\)\"O" "\\1Ö")
113 ("\\([-a-zA-Z\"`]\\)\"u" "\\1ü")
114 ("\\([-a-zA-Z\"`]\\)\"U" "\\1Ü")
115 ("\\([-a-zA-Z\"`]\\)\"s" "\\1ß")
116 ("\\([-a-zA-Z\"`]\\)\\\\3" "\\1ß")
117 )
118 "German translation table.
119 This table uses a conservative translation approach and may translate too
120 little.")
121
122 (defvar iso-german-trans-tab iso-aggressive-german-trans-tab
123 "Currently active translation table for German.")
124
125 ;;;###autoload
126 (defun iso-german (from to &optional buffer)
127 "Translate net conventions for German to ISO 8859-1.
128 The region between FROM and TO is translated using the table TRANS-TAB.
129 Optional arg BUFFER is ignored (for use in `format-alist')."
130 (interactive "*r")
131 (iso-translate-conventions from to iso-german-trans-tab))
132
133 (defvar iso-iso2tex-trans-tab
134 '(
135 ("ä" "{\\\\\"a}")
136 ("à" "{\\\\`a}")
137 ("á" "{\\\\'a}")
138 ("ã" "{\\\\~a}")
139 ("â" "{\\\\^a}")
140 ("ë" "{\\\\\"e}")
141 ("è" "{\\\\`e}")
142 ("é" "{\\\\'e}")
143 ("ê" "{\\\\^e}")
144 ("ï" "{\\\\\"\\\\i}")
145 ("ì" "{\\\\`\\\\i}")
146 ("í" "{\\\\'\\\\i}")
147 ("î" "{\\\\^\\\\i}")
148 ("ö" "{\\\\\"o}")
149 ("ò" "{\\\\`o}")
150 ("ó" "{\\\\'o}")
151 ("õ" "{\\\\~o}")
152 ("ô" "{\\\\^o}")
153 ("ü" "{\\\\\"u}")
154 ("ù" "{\\\\`u}")
155 ("ú" "{\\\\'u}")
156 ("û" "{\\\\^u}")
157 ("Ä" "{\\\\\"A}")
158 ("À" "{\\\\`A}")
159 ("Á" "{\\\\'A}")
160 ("Ã" "{\\\\~A}")
161 ("Â" "{\\\\^A}")
162 ("Ë" "{\\\\\"E}")
163 ("È" "{\\\\`E}")
164 ("É" "{\\\\'E}")
165 ("Ê" "{\\\\^E}")
166 ("Ï" "{\\\\\"I}")
167 ("Ì" "{\\\\`I}")
168 ("Í" "{\\\\'I}")
169 ("Î" "{\\\\^I}")
170 ("Ö" "{\\\\\"O}")
171 ("Ò" "{\\\\`O}")
172 ("Ó" "{\\\\'O}")
173 ("Õ" "{\\\\~O}")
174 ("Ô" "{\\\\^O}")
175 ("Ü" "{\\\\\"U}")
176 ("Ù" "{\\\\`U}")
177 ("Ú" "{\\\\'U}")
178 ("Û" "{\\\\^U}")
179 ("ñ" "{\\\\~n}")
180 ("Ñ" "{\\\\~N}")
181 ("ç" "{\\\\c c}")
182 ("Ç" "{\\\\c C}")
183 ("ß" "{\\\\ss}")
184 ("\306" "{\\\\AE}")
185 ("\346" "{\\\\ae}")
186 ("\305" "{\\\\AA}")
187 ("\345" "{\\\\aa}")
188 ("\251" "{\\\\copyright}")
189 ("£" "{\\\\pounds}")
190 ("¶" "{\\\\P}")
191 ("§" "{\\\\S}")
192 ("¿" "{?`}")
193 ("¡" "{!`}")
194 )
195 "Translation table for translating ISO 8859-1 characters to TeX sequences.")
196
197 ;;;###autoload
198 (defun iso-iso2tex (from to &optional buffer)
199 "Translate ISO 8859-1 characters to TeX sequences.
200 The region between FROM and TO is translated using the table TRANS-TAB.
201 Optional arg BUFFER is ignored (for use in `format-alist')."
202 (interactive "*r")
203 (iso-translate-conventions from to iso-iso2tex-trans-tab))
204
205 (defvar iso-tex2iso-trans-tab
206 '(
207 ("{\\\\\"a}" "ä")
208 ("{\\\\`a}" "à")
209 ("{\\\\'a}" "á")
210 ("{\\\\~a}" "ã")
211 ("{\\\\^a}" "â")
212 ("{\\\\\"e}" "ë")
213 ("{\\\\`e}" "è")
214 ("{\\\\'e}" "é")
215 ("{\\\\^e}" "ê")
216 ("{\\\\\"\\\\i}" "ï")
217 ("{\\\\`\\\\i}" "ì")
218 ("{\\\\'\\\\i}" "í")
219 ("{\\\\^\\\\i}" "î")
220 ("{\\\\\"i}" "ï")
221 ("{\\\\`i}" "ì")
222 ("{\\\\'i}" "í")
223 ("{\\\\^i}" "î")
224 ("{\\\\\"o}" "ö")
225 ("{\\\\`o}" "ò")
226 ("{\\\\'o}" "ó")
227 ("{\\\\~o}" "õ")
228 ("{\\\\^o}" "ô")
229 ("{\\\\\"u}" "ü")
230 ("{\\\\`u}" "ù")
231 ("{\\\\'u}" "ú")
232 ("{\\\\^u}" "û")
233 ("{\\\\\"A}" "Ä")
234 ("{\\\\`A}" "À")
235 ("{\\\\'A}" "Á")
236 ("{\\\\~A}" "Ã")
237 ("{\\\\^A}" "Â")
238 ("{\\\\\"E}" "Ë")
239 ("{\\\\`E}" "È")
240 ("{\\\\'E}" "É")
241 ("{\\\\^E}" "Ê")
242 ("{\\\\\"I}" "Ï")
243 ("{\\\\`I}" "Ì")
244 ("{\\\\'I}" "Í")
245 ("{\\\\^I}" "Î")
246 ("{\\\\\"O}" "Ö")
247 ("{\\\\`O}" "Ò")
248 ("{\\\\'O}" "Ó")
249 ("{\\\\~O}" "Õ")
250 ("{\\\\^O}" "Ô")
251 ("{\\\\\"U}" "Ü")
252 ("{\\\\`U}" "Ù")
253 ("{\\\\'U}" "Ú")
254 ("{\\\\^U}" "Û")
255 ("{\\\\~n}" "ñ")
256 ("{\\\\~N}" "Ñ")
257 ("{\\\\c c}" "ç")
258 ("{\\\\c C}" "Ç")
259 ("\\\\\"a" "ä")
260 ("\\\\`a" "à")
261 ("\\\\'a" "á")
262 ("\\\\~a" "ã")
263 ("\\\\^a" "â")
264 ("\\\\\"e" "ë")
265 ("\\\\`e" "è")
266 ("\\\\'e" "é")
267 ("\\\\^e" "ê")
268 ("\\\\\"\\\\i" "ï")
269 ("\\\\`\\\\i" "ì")
270 ("\\\\'\\\\i" "í")
271 ("\\\\^\\\\i" "î")
272 ("\\\\\"i" "ï")
273 ("\\\\`i" "ì")
274 ("\\\\'i" "í")
275 ("\\\\^i" "î")
276 ("\\\\\"o" "ö")
277 ("\\\\`o" "ò")
278 ("\\\\'o" "ó")
279 ("\\\\~o" "õ")
280 ("\\\\^o" "ô")
281 ("\\\\\"u" "ü")
282 ("\\\\`u" "ù")
283 ("\\\\'u" "ú")
284 ("\\\\^u" "û")
285 ("\\\\\"A" "Ä")
286 ("\\\\`A" "À")
287 ("\\\\'A" "Á")
288 ("\\\\~A" "Ã")
289 ("\\\\^A" "Â")
290 ("\\\\\"E" "Ë")
291 ("\\\\`E" "È")
292 ("\\\\'E" "É")
293 ("\\\\^E" "Ê")
294 ("\\\\\"I" "Ï")
295 ("\\\\`I" "Ì")
296 ("\\\\'I" "Í")
297 ("\\\\^I" "Î")
298 ("\\\\\"O" "Ö")
299 ("\\\\`O" "Ò")
300 ("\\\\'O" "Ó")
301 ("\\\\~O" "Õ")
302 ("\\\\^O" "Ô")
303 ("\\\\\"U" "Ü")
304 ("\\\\`U" "Ù")
305 ("\\\\'U" "Ú")
306 ("\\\\^U" "Û")
307 ("\\\\~n" "ñ")
308 ("\\\\~N" "Ñ")
309 ("\\\\\"{a}" "ä")
310 ("\\\\`{a}" "à")
311 ("\\\\'{a}" "á")
312 ("\\\\~{a}" "ã")
313 ("\\\\^{a}" "â")
314 ("\\\\\"{e}" "ë")
315 ("\\\\`{e}" "è")
316 ("\\\\'{e}" "é")
317 ("\\\\^{e}" "ê")
318 ("\\\\\"{\\\\i}" "ï")
319 ("\\\\`{\\\\i}" "ì")
320 ("\\\\'{\\\\i}" "í")
321 ("\\\\^{\\\\i}" "î")
322 ("\\\\\"{i}" "ï")
323 ("\\\\`{i}" "ì")
324 ("\\\\'{i}" "í")
325 ("\\\\^{i}" "î")
326 ("\\\\\"{o}" "ö")
327 ("\\\\`{o}" "ò")
328 ("\\\\'{o}" "ó")
329 ("\\\\~{o}" "õ")
330 ("\\\\^{o}" "ô")
331 ("\\\\\"{u}" "ü")
332 ("\\\\`{u}" "ù")
333 ("\\\\'{u}" "ú")
334 ("\\\\^{u}" "û")
335 ("\\\\\"{A}" "Ä")
336 ("\\\\`{A}" "À")
337 ("\\\\'{A}" "Á")
338 ("\\\\~{A}" "Ã")
339 ("\\\\^{A}" "Â")
340 ("\\\\\"{E}" "Ë")
341 ("\\\\`{E}" "È")
342 ("\\\\'{E}" "É")
343 ("\\\\^{E}" "Ê")
344 ("\\\\\"{I}" "Ï")
345 ("\\\\`{I}" "Ì")
346 ("\\\\'{I}" "Í")
347 ("\\\\^{I}" "Î")
348 ("\\\\\"{O}" "Ö")
349 ("\\\\`{O}" "Ò")
350 ("\\\\'{O}" "Ó")
351 ("\\\\~{O}" "Õ")
352 ("\\\\^{O}" "Ô")
353 ("\\\\\"{U}" "Ü")
354 ("\\\\`{U}" "Ù")
355 ("\\\\'{U}" "Ú")
356 ("\\\\^{U}" "Û")
357 ("\\\\~{n}" "ñ")
358 ("\\\\~{N}" "Ñ")
359 ("\\\\c{c}" "ç")
360 ("\\\\c{C}" "Ç")
361 ("{\\\\ss}" "ß")
362 ("{\\\\AE}" "\306")
363 ("{\\\\ae}" "\346")
364 ("{\\\\AA}" "\305")
365 ("{\\\\aa}" "\345")
366 ("{\\\\copyright}" "\251")
367 ("\\\\copyright{}" "\251")
368 ("{\\\\pounds}" "£" )
369 ("{\\\\P}" "¶" )
370 ("{\\\\S}" "§" )
371 ("\\\\pounds{}" "£" )
372 ("\\\\P{}" "¶" )
373 ("\\\\S{}" "§" )
374 ("{\\?`}" "¿")
375 ("{!`}" "¡")
376 ("\\?`" "¿")
377 ("!`" "¡")
378 )
379 "Translation table for translating TeX sequences to ISO 8859-1 characters.
380 This table is not exhaustive (and due to TeX's power can never be). It only
381 contains commonly used sequences.")
382
383 ;;;###autoload
384 (defun iso-tex2iso (from to &optional buffer)
385 "Translate TeX sequences to ISO 8859-1 characters.
386 The region between FROM and TO is translated using the table TRANS-TAB.
387 Optional arg BUFFER is ignored (for use in `format-alist')."
388 (interactive "*r")
389 (iso-translate-conventions from to iso-tex2iso-trans-tab))
390
391 (defvar iso-gtex2iso-trans-tab
392 '(
393 ("{\\\\\"a}" "ä")
394 ("{\\\\`a}" "à")
395 ("{\\\\'a}" "á")
396 ("{\\\\~a}" "ã")
397 ("{\\\\^a}" "â")
398 ("{\\\\\"e}" "ë")
399 ("{\\\\`e}" "è")
400 ("{\\\\'e}" "é")
401 ("{\\\\^e}" "ê")
402 ("{\\\\\"\\\\i}" "ï")
403 ("{\\\\`\\\\i}" "ì")
404 ("{\\\\'\\\\i}" "í")
405 ("{\\\\^\\\\i}" "î")
406 ("{\\\\\"i}" "ï")
407 ("{\\\\`i}" "ì")
408 ("{\\\\'i}" "í")
409 ("{\\\\^i}" "î")
410 ("{\\\\\"o}" "ö")
411 ("{\\\\`o}" "ò")
412 ("{\\\\'o}" "ó")
413 ("{\\\\~o}" "õ")
414 ("{\\\\^o}" "ô")
415 ("{\\\\\"u}" "ü")
416 ("{\\\\`u}" "ù")
417 ("{\\\\'u}" "ú")
418 ("{\\\\^u}" "û")
419 ("{\\\\\"A}" "Ä")
420 ("{\\\\`A}" "À")
421 ("{\\\\'A}" "Á")
422 ("{\\\\~A}" "Ã")
423 ("{\\\\^A}" "Â")
424 ("{\\\\\"E}" "Ë")
425 ("{\\\\`E}" "È")
426 ("{\\\\'E}" "É")
427 ("{\\\\^E}" "Ê")
428 ("{\\\\\"I}" "Ï")
429 ("{\\\\`I}" "Ì")
430 ("{\\\\'I}" "Í")
431 ("{\\\\^I}" "Î")
432 ("{\\\\\"O}" "Ö")
433 ("{\\\\`O}" "Ò")
434 ("{\\\\'O}" "Ó")
435 ("{\\\\~O}" "Õ")
436 ("{\\\\^O}" "Ô")
437 ("{\\\\\"U}" "Ü")
438 ("{\\\\`U}" "Ù")
439 ("{\\\\'U}" "Ú")
440 ("{\\\\^U}" "Û")
441 ("{\\\\~n}" "ñ")
442 ("{\\\\~N}" "Ñ")
443 ("{\\\\c c}" "ç")
444 ("{\\\\c C}" "Ç")
445 ("\\\\\"a" "ä")
446 ("\\\\`a" "à")
447 ("\\\\'a" "á")
448 ("\\\\~a" "ã")
449 ("\\\\^a" "â")
450 ("\\\\\"e" "ë")
451 ("\\\\`e" "è")
452 ("\\\\'e" "é")
453 ("\\\\^e" "ê")
454 ("\\\\\"\\\\i" "ï")
455 ("\\\\`\\\\i" "ì")
456 ("\\\\'\\\\i" "í")
457 ("\\\\^\\\\i" "î")
458 ("\\\\\"i" "ï")
459 ("\\\\`i" "ì")
460 ("\\\\'i" "í")
461 ("\\\\^i" "î")
462 ("\\\\\"o" "ö")
463 ("\\\\`o" "ò")
464 ("\\\\'o" "ó")
465 ("\\\\~o" "õ")
466 ("\\\\^o" "ô")
467 ("\\\\\"u" "ü")
468 ("\\\\`u" "ù")
469 ("\\\\'u" "ú")
470 ("\\\\^u" "û")
471 ("\\\\\"A" "Ä")
472 ("\\\\`A" "À")
473 ("\\\\'A" "Á")
474 ("\\\\~A" "Ã")
475 ("\\\\^A" "Â")
476 ("\\\\\"E" "Ë")
477 ("\\\\`E" "È")
478 ("\\\\'E" "É")
479 ("\\\\^E" "Ê")
480 ("\\\\\"I" "Ï")
481 ("\\\\`I" "Ì")
482 ("\\\\'I" "Í")
483 ("\\\\^I" "Î")
484 ("\\\\\"O" "Ö")
485 ("\\\\`O" "Ò")
486 ("\\\\'O" "Ó")
487 ("\\\\~O" "Õ")
488 ("\\\\^O" "Ô")
489 ("\\\\\"U" "Ü")
490 ("\\\\`U" "Ù")
491 ("\\\\'U" "Ú")
492 ("\\\\^U" "Û")
493 ("\\\\~n" "ñ")
494 ("\\\\~N" "Ñ")
495 ("\\\\\"{a}" "ä")
496 ("\\\\`{a}" "à")
497 ("\\\\'{a}" "á")
498 ("\\\\~{a}" "ã")
499 ("\\\\^{a}" "â")
500 ("\\\\\"{e}" "ë")
501 ("\\\\`{e}" "è")
502 ("\\\\'{e}" "é")
503 ("\\\\^{e}" "ê")
504 ("\\\\\"{\\\\i}" "ï")
505 ("\\\\`{\\\\i}" "ì")
506 ("\\\\'{\\\\i}" "í")
507 ("\\\\^{\\\\i}" "î")
508 ("\\\\\"{i}" "ï")
509 ("\\\\`{i}" "ì")
510 ("\\\\'{i}" "í")
511 ("\\\\^{i}" "î")
512 ("\\\\\"{o}" "ö")
513 ("\\\\`{o}" "ò")
514 ("\\\\'{o}" "ó")
515 ("\\\\~{o}" "õ")
516 ("\\\\^{o}" "ô")
517 ("\\\\\"{u}" "ü")
518 ("\\\\`{u}" "ù")
519 ("\\\\'{u}" "ú")
520 ("\\\\^{u}" "û")
521 ("\\\\\"{A}" "Ä")
522 ("\\\\`{A}" "À")
523 ("\\\\'{A}" "Á")
524 ("\\\\~{A}" "Ã")
525 ("\\\\^{A}" "Â")
526 ("\\\\\"{E}" "Ë")
527 ("\\\\`{E}" "È")
528 ("\\\\'{E}" "É")
529 ("\\\\^{E}" "Ê")
530 ("\\\\\"{I}" "Ï")
531 ("\\\\`{I}" "Ì")
532 ("\\\\'{I}" "Í")
533 ("\\\\^{I}" "Î")
534 ("\\\\\"{O}" "Ö")
535 ("\\\\`{O}" "Ò")
536 ("\\\\'{O}" "Ó")
537 ("\\\\~{O}" "Õ")
538 ("\\\\^{O}" "Ô")
539 ("\\\\\"{U}" "Ü")
540 ("\\\\`{U}" "Ù")
541 ("\\\\'{U}" "Ú")
542 ("\\\\^{U}" "Û")
543 ("\\\\~{n}" "ñ")
544 ("\\\\~{N}" "Ñ")
545 ("\\\\c{c}" "ç")
546 ("\\\\c{C}" "Ç")
547 ("{\\\\ss}" "ß")
548 ("{\\\\AE}" "\306")
549 ("{\\\\ae}" "\346")
550 ("{\\\\AA}" "\305")
551 ("{\\\\aa}" "\345")
552 ("{\\\\copyright}" "\251")
553 ("\\\\copyright{}" "\251")
554 ("{\\\\pounds}" "£" )
555 ("{\\\\P}" "¶" )
556 ("{\\\\S}" "§" )
557 ("\\\\pounds{}" "£" )
558 ("\\\\P{}" "¶" )
559 ("\\\\S{}" "§" )
560 ("?`" "¿")
561 ("!`" "¡")
562 ("{?`}" "¿")
563 ("{!`}" "¡")
564 ("\"a" "ä")
565 ("\"A" "Ä")
566 ("\"o" "ö")
567 ("\"O" "Ö")
568 ("\"u" "ü")
569 ("\"U" "Ü")
570 ("\"s" "ß")
571 ("\\\\3" "ß")
572 )
573 "Translation table for translating German TeX sequences to ISO 8859-1.
574 This table is not exhaustive (and due to TeX's power can never be). It only
575 contains commonly used sequences.")
576
577 (defvar iso-iso2gtex-trans-tab
578 '(
579 ("ä" "\"a")
580 ("à" "{\\\\`a}")
581 ("á" "{\\\\'a}")
582 ("ã" "{\\\\~a}")
583 ("â" "{\\\\^a}")
584 ("ë" "{\\\\\"e}")
585 ("è" "{\\\\`e}")
586 ("é" "{\\\\'e}")
587 ("ê" "{\\\\^e}")
588 ("ï" "{\\\\\"\\\\i}")
589 ("ì" "{\\\\`\\\\i}")
590 ("í" "{\\\\'\\\\i}")
591 ("î" "{\\\\^\\\\i}")
592 ("ö" "\"o")
593 ("ò" "{\\\\`o}")
594 ("ó" "{\\\\'o}")
595 ("õ" "{\\\\~o}")
596 ("ô" "{\\\\^o}")
597 ("ü" "\"u")
598 ("ù" "{\\\\`u}")
599 ("ú" "{\\\\'u}")
600 ("û" "{\\\\^u}")
601 ("Ä" "\"A")
602 ("À" "{\\\\`A}")
603 ("Á" "{\\\\'A}")
604 ("Ã" "{\\\\~A}")
605 ("Â" "{\\\\^A}")
606 ("Ë" "{\\\\\"E}")
607 ("È" "{\\\\`E}")
608 ("É" "{\\\\'E}")
609 ("Ê" "{\\\\^E}")
610 ("Ï" "{\\\\\"I}")
611 ("Ì" "{\\\\`I}")
612 ("Í" "{\\\\'I}")
613 ("Î" "{\\\\^I}")
614 ("Ö" "\"O")
615 ("Ò" "{\\\\`O}")
616 ("Ó" "{\\\\'O}")
617 ("Õ" "{\\\\~O}")
618 ("Ô" "{\\\\^O}")
619 ("Ü" "\"U")
620 ("Ù" "{\\\\`U}")
621 ("Ú" "{\\\\'U}")
622 ("Û" "{\\\\^U}")
623 ("ñ" "{\\\\~n}")
624 ("Ñ" "{\\\\~N}")
625 ("ç" "{\\\\c c}")
626 ("Ç" "{\\\\c C}")
627 ("ß" "\"s")
628 ("\306" "{\\\\AE}")
629 ("\346" "{\\\\ae}")
630 ("\305" "{\\\\AA}")
631 ("\345" "{\\\\aa}")
632 ("\251" "{\\\\copyright}")
633 ("£" "{\\\\pounds}")
634 ("¶" "{\\\\P}")
635 ("§" "{\\\\S}")
636 ("¿" "{?`}")
637 ("¡" "{!`}")
638 )
639 "Translation table for translating ISO 8859-1 characters to German TeX.")
640
641 ;;;###autoload
642 (defun iso-gtex2iso (from to &optional buffer)
643 "Translate German TeX sequences to ISO 8859-1 characters.
644 The region between FROM and TO is translated using the table TRANS-TAB.
645 Optional arg BUFFER is ignored (for use in `format-alist')."
646 (interactive "*r")
647 (iso-translate-conventions from to iso-gtex2iso-trans-tab))
648
649 ;;;###autoload
650 (defun iso-iso2gtex (from to &optional buffer)
651 "Translate ISO 8859-1 characters to German TeX sequences.
652 The region between FROM and TO is translated using the table TRANS-TAB.
653 Optional arg BUFFER is ignored (for use in `format-alist')."
654 (interactive "*r")
655 (iso-translate-conventions from to iso-iso2gtex-trans-tab))
656
657 (defvar iso-iso2duden-trans-tab
658 '(("ä" "ae")
659 ("Ä" "Ae")
660 ("ö" "oe")
661 ("Ö" "Oe")
662 ("ü" "ue")
663 ("Ü" "Ue")
664 ("ß" "ss")))
665
666 ;;;###autoload
667 (defun iso-iso2duden (from to &optional buffer)
668 "Translate ISO 8859-1 characters to German TeX sequences.
669 The region between FROM and TO is translated using the table TRANS-TAB.
670 Optional arg BUFFER is ignored (for use in `format-alist')."
671 (interactive "*r")
672 (iso-translate-conventions from to iso-iso2duden-trans-tab))
673
674 (defvar iso-iso2sgml-trans-tab
675 '(("À" "&Agrave;")
676 ("Á" "&Aacute;")
677 ("Â" "&Acirc;")
678 ("Ã" "&Atilde;")
679 ("Ä" "&Auml;")
680 ("Å" "&Aring;")
681 ("Æ" "&AElig;")
682 ("Ç" "&Ccedil;")
683 ("È" "&Egrave;")
684 ("É" "&Eacute;")
685 ("Ê" "&Ecirc;")
686 ("Ë" "&Euml;")
687 ("Ì" "&Igrave;")
688 ("Í" "&Iacute;")
689 ("Î" "&Icirc;")
690 ("Ï" "&Iuml;")
691 ("Ð" "&ETH;")
692 ("Ñ" "&Ntilde;")
693 ("Ò" "&Ograve;")
694 ("Ó" "&Oacute;")
695 ("Ô" "&Ocirc;")
696 ("Õ" "&Otilde;")
697 ("Ö" "&Ouml;")
698 ("Ø" "&Oslash;")
699 ("Ù" "&Ugrave;")
700 ("Ú" "&Uacute;")
701 ("Û" "&Ucirc;")
702 ("Ü" "&Uuml;")
703 ("Ý" "&Yacute;")
704 ("Þ" "&THORN;")
705 ("ß" "&szlig;")
706 ("à" "&agrave;")
707 ("á" "&aacute;")
708 ("â" "&acirc;")
709 ("ã" "&atilde;")
710 ("ä" "&auml;")
711 ("å" "&aring;")
712 ("æ" "&aelig;")
713 ("ç" "&ccedil;")
714 ("è" "&egrave;")
715 ("é" "&eacute;")
716 ("ê" "&ecirc;")
717 ("ë" "&euml;")
718 ("ì" "&igrave;")
719 ("í" "&iacute;")
720 ("î" "&icirc;")
721 ("ï" "&iuml;")
722 ("ð" "&eth;")
723 ("ñ" "&ntilde;")
724 ("ò" "&ograve;")
725 ("ó" "&oacute;")
726 ("ô" "&ocirc;")
727 ("õ" "&otilde;")
728 ("ö" "&ouml;")
729 ("ø" "&oslash;")
730 ("ù" "&ugrave;")
731 ("ú" "&uacute;")
732 ("û" "&ucirc;")
733 ("ü" "&uuml;")
734 ("ý" "&yacute;")
735 ("þ" "&thorn;")
736 ("ÿ" "&yuml;")))
737
738 (defvar iso-sgml2iso-trans-tab
739 '(("&Agrave;" "À")
740 ("&Aacute;" "Á")
741 ("&Acirc;" "Â")
742 ("&Atilde;" "Ã")
743 ("&Auml;" "Ä")
744 ("&Aring;" "Å")
745 ("&AElig;" "Æ")
746 ("&Ccedil;" "Ç")
747 ("&Egrave;" "È")
748 ("&Eacute;" "É")
749 ("&Ecirc;" "Ê")
750 ("&Euml;" "Ë")
751 ("&Igrave;" "Ì")
752 ("&Iacute;" "Í")
753 ("&Icirc;" "Î")
754 ("&Iuml;" "Ï")
755 ("&ETH;" "Ð")
756 ("&Ntilde;" "Ñ")
757 ("&Ograve;" "Ò")
758 ("&Oacute;" "Ó")
759 ("&Ocirc;" "Ô")
760 ("&Otilde;" "Õ")
761 ("&Ouml;" "Ö")
762 ("&Oslash;" "Ø")
763 ("&Ugrave;" "Ù")
764 ("&Uacute;" "Ú")
765 ("&Ucirc;" "Û")
766 ("&Uuml;" "Ü")
767 ("&Yacute;" "Ý")
768 ("&THORN;" "Þ")
769 ("&szlig;" "ß")
770 ("&agrave;" "à")
771 ("&aacute;" "á")
772 ("&acirc;" "â")
773 ("&atilde;" "ã")
774 ("&auml;" "ä")
775 ("&aring;" "å")
776 ("&aelig;" "æ")
777 ("&ccedil;" "ç")
778 ("&egrave;" "è")
779 ("&eacute;" "é")
780 ("&ecirc;" "ê")
781 ("&euml;" "ë")
782 ("&igrave;" "ì")
783 ("&iacute;" "í")
784 ("&icirc;" "î")
785 ("&iuml;" "ï")
786 ("&eth;" "ð")
787 ("&ntilde;" "ñ")
788 ("&ograve;" "ò")
789 ("&oacute;" "ó")
790 ("&ocirc;" "ô")
791 ("&otilde;" "õ")
792 ("&ouml;" "ö")
793 ("&oslash;" "ø")
794 ("&ugrave;" "ù")
795 ("&uacute;" "ú")
796 ("&ucirc;" "û")
797 ("&uuml;" "ü")
798 ("&yacute;" "ý")
799 ("&thorn;" "þ")
800 ("&yuml;" "ÿ")))
801
802 ;;;###autoload
803 (defun iso-iso2sgml (from to &optional buffer)
804 "Translate ISO 8859-1 characters in the region to SGML entities.
805 The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
806 Optional arg BUFFER is ignored (for use in `format-alist')."
807 (interactive "*r")
808 (iso-translate-conventions from to iso-iso2sgml-trans-tab))
809
810 ;;;###autoload
811 (defun iso-sgml2iso (from to &optional buffer)
812 "Translate SGML entities in the region to ISO 8859-1 characters.
813 The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
814 Optional arg BUFFER is ignored (for use in `format-alist')."
815 (interactive "*r")
816 (iso-translate-conventions from to iso-sgml2iso-trans-tab))
817
818 ;;;###autoload
819 (defun iso-cvt-read-only ()
820 "Warn that format is read-only."
821 (interactive)
822 (error "This format is read-only; specify another format for writing"))
823
824 ;;;###autoload
825 (defun iso-cvt-write-only ()
826 "Warn that format is write-only."
827 (interactive)
828 (error "This format is write-only"))
829
830 ;;;###autoload
831 (defun iso-cvt-define-menu ()
832 "Add submenus to the File menu, to convert to and from various formats."
833 (interactive)
834
835 (let ((load-as-menu-map (make-sparse-keymap "Load As..."))
836 (insert-as-menu-map (make-sparse-keymap "Insert As..."))
837 (write-as-menu-map (make-sparse-keymap "Write As..."))
838 (translate-to-menu-map (make-sparse-keymap "Translate to..."))
839 (translate-from-menu-map (make-sparse-keymap "Translate from..."))
840 (menu menu-bar-file-menu))
841
842 (define-key menu [load-as-separator] '("--"))
843
844 (define-key menu [load-as] '("Load As..." . iso-cvt-load-as))
845 (fset 'iso-cvt-load-as load-as-menu-map)
846
847 ;;(define-key menu [insert-as] '("Insert As..." . iso-cvt-insert-as))
848 (fset 'iso-cvt-insert-as insert-as-menu-map)
849
850 (define-key menu [write-as] '("Write As..." . iso-cvt-write-as))
851 (fset 'iso-cvt-write-as write-as-menu-map)
852
853 (define-key menu [translate-separator] '("--"))
854
855 (define-key menu [translate-to] '("Translate to..." . iso-cvt-translate-to))
856 (fset 'iso-cvt-translate-to translate-to-menu-map)
857
858 (define-key menu [translate-from] '("Translate from..." . iso-cvt-translate-from))
859 (fset 'iso-cvt-translate-from translate-from-menu-map)
860
861 (dolist (file-type (reverse format-alist))
862 (let ((name (car file-type))
863 (str-name (cadr file-type)))
864 (if (stringp str-name)
865 (progn
866 (define-key load-as-menu-map (vector name)
867 (cons str-name
868 `(lambda (file)
869 (interactive ,(format "FFind file (as %s): " name))
870 (format-find-file file ',name))))
871 (define-key insert-as-menu-map (vector name)
872 (cons str-name
873 `(lambda (file)
874 (interactive (format "FInsert file (as %s): " ,name))
875 (format-insert-file file ',name))))
876 (define-key write-as-menu-map (vector name)
877 (cons str-name
878 `(lambda (file)
879 (interactive (format "FWrite file (as %s): " ,name))
880 (format-write-file file ',name))))
881 (define-key translate-to-menu-map (vector name)
882 (cons str-name
883 `(lambda ()
884 (interactive)
885 (format-encode-buffer ',name))))
886 (define-key translate-from-menu-map (vector name)
887 (cons str-name
888 `(lambda ()
889 (interactive)
890 (format-decode-buffer ',name))))))))))
891
892 (provide 'iso-cvt)
893
894 ;; arch-tag: 64ae843f-ed0e-43e1-ba50-ffd581b90840
895 ;;; iso-cvt.el ends here