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