(latexenc-find-file-coding-system): Don't inherit the EOL part of the
[emacs.git] / lisp / international / iso-cvt.el
blobf7e325b0ca308c4847bcbbb54a1313c505b40331
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, 1997, 1998, 2000, 2003, 2004
5 ;; Free Software Foundation, Inc.
7 ;; Author: Michael Gschwind <mike@vlsivie.tuwien.ac.at>
8 ;; Keywords: tex, iso, latin, i18n
10 ;; This file is part of GNU Emacs.
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.
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.
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.
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
37 ; TO DO:
38 ; Cover more cases for translation. (There is an infinite number of ways to
39 ; represent accented characters in TeX)
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
47 ;;; Code:
49 (defvar iso-spanish-trans-tab
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Í")
65 "Spanish translation table.")
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))))
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))
92 (defvar iso-aggressive-german-trans-tab
94 ("\"a" "ä")
95 ("\"A" "Ä")
96 ("\"o" "ö")
97 ("\"O" "Ö")
98 ("\"u" "ü")
99 ("\"U" "Ü")
100 ("\"s" "ß")
101 ("\\\\3" "ß")
103 "German translation table.
104 This table uses an aggressive translation approach and may erroneously
105 translate too much.")
107 (defvar iso-conservative-german-trans-tab
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ß")
118 "German translation table.
119 This table uses a conservative translation approach and may translate too
120 little.")
122 (defvar iso-german-trans-tab iso-aggressive-german-trans-tab
123 "Currently active translation table for German.")
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))
133 (defvar iso-iso2tex-trans-tab
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 ("¡" "{!`}")
195 "Translation table for translating ISO 8859-1 characters to TeX sequences.")
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))
205 (defvar iso-tex2iso-trans-tab
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 ;; Discard spaces and/or one EOF after macro \i.
269 ;; Converting it back will use braces.
270 ("\\\\\"\\\\i *\n\n" \n\n")
271 ("\\\\\"\\\\i *\n?" "ï")
272 ("\\\\`\\\\i *\n\n" \n\n")
273 ("\\\\`\\\\i *\n?" "ì")
274 ("\\\\'\\\\i *\n\n" \n\n")
275 ("\\\\'\\\\i *\n?" "í")
276 ("\\\\^\\\\i *\n\n" \n\n")
277 ("\\\\^\\\\i *\n?" "î")
278 ("\\\\\"i" "ï")
279 ("\\\\`i" "ì")
280 ("\\\\'i" "í")
281 ("\\\\^i" "î")
282 ("\\\\\"o" "ö")
283 ("\\\\`o" "ò")
284 ("\\\\'o" "ó")
285 ("\\\\~o" "õ")
286 ("\\\\^o" "ô")
287 ("\\\\\"u" "ü")
288 ("\\\\`u" "ù")
289 ("\\\\'u" "ú")
290 ("\\\\^u" "û")
291 ("\\\\\"A" "Ä")
292 ("\\\\`A" "À")
293 ("\\\\'A" "Á")
294 ("\\\\~A" "Ã")
295 ("\\\\^A" "Â")
296 ("\\\\\"E" "Ë")
297 ("\\\\`E" "È")
298 ("\\\\'E" "É")
299 ("\\\\^E" "Ê")
300 ("\\\\\"I" "Ï")
301 ("\\\\`I" "Ì")
302 ("\\\\'I" "Í")
303 ("\\\\^I" "Î")
304 ("\\\\\"O" "Ö")
305 ("\\\\`O" "Ò")
306 ("\\\\'O" "Ó")
307 ("\\\\~O" "Õ")
308 ("\\\\^O" "Ô")
309 ("\\\\\"U" "Ü")
310 ("\\\\`U" "Ù")
311 ("\\\\'U" "Ú")
312 ("\\\\^U" "Û")
313 ("\\\\~n" "ñ")
314 ("\\\\~N" "Ñ")
315 ("\\\\\"{a}" "ä")
316 ("\\\\`{a}" "à")
317 ("\\\\'{a}" "á")
318 ("\\\\~{a}" "ã")
319 ("\\\\^{a}" "â")
320 ("\\\\\"{e}" "ë")
321 ("\\\\`{e}" "è")
322 ("\\\\'{e}" "é")
323 ("\\\\^{e}" "ê")
324 ("\\\\\"{\\\\i}" "ï")
325 ("\\\\`{\\\\i}" "ì")
326 ("\\\\'{\\\\i}" "í")
327 ("\\\\^{\\\\i}" "î")
328 ("\\\\\"{i}" "ï")
329 ("\\\\`{i}" "ì")
330 ("\\\\'{i}" "í")
331 ("\\\\^{i}" "î")
332 ("\\\\\"{o}" "ö")
333 ("\\\\`{o}" "ò")
334 ("\\\\'{o}" "ó")
335 ("\\\\~{o}" "õ")
336 ("\\\\^{o}" "ô")
337 ("\\\\\"{u}" "ü")
338 ("\\\\`{u}" "ù")
339 ("\\\\'{u}" "ú")
340 ("\\\\^{u}" "û")
341 ("\\\\\"{A}" "Ä")
342 ("\\\\`{A}" "À")
343 ("\\\\'{A}" "Á")
344 ("\\\\~{A}" "Ã")
345 ("\\\\^{A}" "Â")
346 ("\\\\\"{E}" "Ë")
347 ("\\\\`{E}" "È")
348 ("\\\\'{E}" "É")
349 ("\\\\^{E}" "Ê")
350 ("\\\\\"{I}" "Ï")
351 ("\\\\`{I}" "Ì")
352 ("\\\\'{I}" "Í")
353 ("\\\\^{I}" "Î")
354 ("\\\\\"{O}" "Ö")
355 ("\\\\`{O}" "Ò")
356 ("\\\\'{O}" "Ó")
357 ("\\\\~{O}" "Õ")
358 ("\\\\^{O}" "Ô")
359 ("\\\\\"{U}" "Ü")
360 ("\\\\`{U}" "Ù")
361 ("\\\\'{U}" "Ú")
362 ("\\\\^{U}" "Û")
363 ("\\\\~{n}" "ñ")
364 ("\\\\~{N}" "Ñ")
365 ("\\\\c{c}" "ç")
366 ("\\\\c{C}" "Ç")
367 ("{\\\\ss}" "ß")
368 ("{\\\\AE}" "\306")
369 ("{\\\\ae}" "\346")
370 ("{\\\\AA}" "\305")
371 ("{\\\\aa}" "\345")
372 ("{\\\\copyright}" "\251")
373 ("\\\\copyright{}" "\251")
374 ("{\\\\pounds}" "£" )
375 ("{\\\\P}" "¶" )
376 ("{\\\\S}" "§" )
377 ("\\\\pounds{}" "£" )
378 ("\\\\P{}" "¶" )
379 ("\\\\S{}" "§" )
380 ("{\\?`}" "¿")
381 ("{!`}" "¡")
382 ("\\?`" "¿")
383 ("!`" "¡")
385 "Translation table for translating TeX sequences to ISO 8859-1 characters.
386 This table is not exhaustive (and due to TeX's power can never be). It only
387 contains commonly used sequences.")
389 ;;;###autoload
390 (defun iso-tex2iso (from to &optional buffer)
391 "Translate TeX sequences to ISO 8859-1 characters.
392 The region between FROM and TO is translated using the table TRANS-TAB.
393 Optional arg BUFFER is ignored (for use in `format-alist')."
394 (interactive "*r")
395 (iso-translate-conventions from to iso-tex2iso-trans-tab))
397 (defvar iso-gtex2iso-trans-tab
399 ("{\\\\\"a}" "ä")
400 ("{\\\\`a}" "à")
401 ("{\\\\'a}" "á")
402 ("{\\\\~a}" "ã")
403 ("{\\\\^a}" "â")
404 ("{\\\\\"e}" "ë")
405 ("{\\\\`e}" "è")
406 ("{\\\\'e}" "é")
407 ("{\\\\^e}" "ê")
408 ("{\\\\\"\\\\i}" "ï")
409 ("{\\\\`\\\\i}" "ì")
410 ("{\\\\'\\\\i}" "í")
411 ("{\\\\^\\\\i}" "î")
412 ("{\\\\\"i}" "ï")
413 ("{\\\\`i}" "ì")
414 ("{\\\\'i}" "í")
415 ("{\\\\^i}" "î")
416 ("{\\\\\"o}" "ö")
417 ("{\\\\`o}" "ò")
418 ("{\\\\'o}" "ó")
419 ("{\\\\~o}" "õ")
420 ("{\\\\^o}" "ô")
421 ("{\\\\\"u}" "ü")
422 ("{\\\\`u}" "ù")
423 ("{\\\\'u}" "ú")
424 ("{\\\\^u}" "û")
425 ("{\\\\\"A}" "Ä")
426 ("{\\\\`A}" "À")
427 ("{\\\\'A}" "Á")
428 ("{\\\\~A}" "Ã")
429 ("{\\\\^A}" "Â")
430 ("{\\\\\"E}" "Ë")
431 ("{\\\\`E}" "È")
432 ("{\\\\'E}" "É")
433 ("{\\\\^E}" "Ê")
434 ("{\\\\\"I}" "Ï")
435 ("{\\\\`I}" "Ì")
436 ("{\\\\'I}" "Í")
437 ("{\\\\^I}" "Î")
438 ("{\\\\\"O}" "Ö")
439 ("{\\\\`O}" "Ò")
440 ("{\\\\'O}" "Ó")
441 ("{\\\\~O}" "Õ")
442 ("{\\\\^O}" "Ô")
443 ("{\\\\\"U}" "Ü")
444 ("{\\\\`U}" "Ù")
445 ("{\\\\'U}" "Ú")
446 ("{\\\\^U}" "Û")
447 ("{\\\\~n}" "ñ")
448 ("{\\\\~N}" "Ñ")
449 ("{\\\\c c}" "ç")
450 ("{\\\\c C}" "Ç")
451 ("\\\\\"a" "ä")
452 ("\\\\`a" "à")
453 ("\\\\'a" "á")
454 ("\\\\~a" "ã")
455 ("\\\\^a" "â")
456 ("\\\\\"e" "ë")
457 ("\\\\`e" "è")
458 ("\\\\'e" "é")
459 ("\\\\^e" "ê")
460 ("\\\\\"\\\\i" "ï")
461 ("\\\\`\\\\i" "ì")
462 ("\\\\'\\\\i" "í")
463 ("\\\\^\\\\i" "î")
464 ("\\\\\"i" "ï")
465 ("\\\\`i" "ì")
466 ("\\\\'i" "í")
467 ("\\\\^i" "î")
468 ("\\\\\"o" "ö")
469 ("\\\\`o" "ò")
470 ("\\\\'o" "ó")
471 ("\\\\~o" "õ")
472 ("\\\\^o" "ô")
473 ("\\\\\"u" "ü")
474 ("\\\\`u" "ù")
475 ("\\\\'u" "ú")
476 ("\\\\^u" "û")
477 ("\\\\\"A" "Ä")
478 ("\\\\`A" "À")
479 ("\\\\'A" "Á")
480 ("\\\\~A" "Ã")
481 ("\\\\^A" "Â")
482 ("\\\\\"E" "Ë")
483 ("\\\\`E" "È")
484 ("\\\\'E" "É")
485 ("\\\\^E" "Ê")
486 ("\\\\\"I" "Ï")
487 ("\\\\`I" "Ì")
488 ("\\\\'I" "Í")
489 ("\\\\^I" "Î")
490 ("\\\\\"O" "Ö")
491 ("\\\\`O" "Ò")
492 ("\\\\'O" "Ó")
493 ("\\\\~O" "Õ")
494 ("\\\\^O" "Ô")
495 ("\\\\\"U" "Ü")
496 ("\\\\`U" "Ù")
497 ("\\\\'U" "Ú")
498 ("\\\\^U" "Û")
499 ("\\\\~n" "ñ")
500 ("\\\\~N" "Ñ")
501 ("\\\\\"{a}" "ä")
502 ("\\\\`{a}" "à")
503 ("\\\\'{a}" "á")
504 ("\\\\~{a}" "ã")
505 ("\\\\^{a}" "â")
506 ("\\\\\"{e}" "ë")
507 ("\\\\`{e}" "è")
508 ("\\\\'{e}" "é")
509 ("\\\\^{e}" "ê")
510 ("\\\\\"{\\\\i}" "ï")
511 ("\\\\`{\\\\i}" "ì")
512 ("\\\\'{\\\\i}" "í")
513 ("\\\\^{\\\\i}" "î")
514 ("\\\\\"{i}" "ï")
515 ("\\\\`{i}" "ì")
516 ("\\\\'{i}" "í")
517 ("\\\\^{i}" "î")
518 ("\\\\\"{o}" "ö")
519 ("\\\\`{o}" "ò")
520 ("\\\\'{o}" "ó")
521 ("\\\\~{o}" "õ")
522 ("\\\\^{o}" "ô")
523 ("\\\\\"{u}" "ü")
524 ("\\\\`{u}" "ù")
525 ("\\\\'{u}" "ú")
526 ("\\\\^{u}" "û")
527 ("\\\\\"{A}" "Ä")
528 ("\\\\`{A}" "À")
529 ("\\\\'{A}" "Á")
530 ("\\\\~{A}" "Ã")
531 ("\\\\^{A}" "Â")
532 ("\\\\\"{E}" "Ë")
533 ("\\\\`{E}" "È")
534 ("\\\\'{E}" "É")
535 ("\\\\^{E}" "Ê")
536 ("\\\\\"{I}" "Ï")
537 ("\\\\`{I}" "Ì")
538 ("\\\\'{I}" "Í")
539 ("\\\\^{I}" "Î")
540 ("\\\\\"{O}" "Ö")
541 ("\\\\`{O}" "Ò")
542 ("\\\\'{O}" "Ó")
543 ("\\\\~{O}" "Õ")
544 ("\\\\^{O}" "Ô")
545 ("\\\\\"{U}" "Ü")
546 ("\\\\`{U}" "Ù")
547 ("\\\\'{U}" "Ú")
548 ("\\\\^{U}" "Û")
549 ("\\\\~{n}" "ñ")
550 ("\\\\~{N}" "Ñ")
551 ("\\\\c{c}" "ç")
552 ("\\\\c{C}" "Ç")
553 ("{\\\\ss}" "ß")
554 ("{\\\\AE}" "\306")
555 ("{\\\\ae}" "\346")
556 ("{\\\\AA}" "\305")
557 ("{\\\\aa}" "\345")
558 ("{\\\\copyright}" "\251")
559 ("\\\\copyright{}" "\251")
560 ("{\\\\pounds}" "£" )
561 ("{\\\\P}" "¶" )
562 ("{\\\\S}" "§" )
563 ("\\\\pounds{}" "£" )
564 ("\\\\P{}" "¶" )
565 ("\\\\S{}" "§" )
566 ("?`" "¿")
567 ("!`" "¡")
568 ("{?`}" "¿")
569 ("{!`}" "¡")
570 ("\"a" "ä")
571 ("\"A" "Ä")
572 ("\"o" "ö")
573 ("\"O" "Ö")
574 ("\"u" "ü")
575 ("\"U" "Ü")
576 ("\"s" "ß")
577 ("\\\\3" "ß")
579 "Translation table for translating German TeX sequences to ISO 8859-1.
580 This table is not exhaustive (and due to TeX's power can never be). It only
581 contains commonly used sequences.")
583 (defvar iso-iso2gtex-trans-tab
585 ("ä" "\"a")
586 ("à" "{\\\\`a}")
587 ("á" "{\\\\'a}")
588 ("ã" "{\\\\~a}")
589 ("â" "{\\\\^a}")
590 ("ë" "{\\\\\"e}")
591 ("è" "{\\\\`e}")
592 ("é" "{\\\\'e}")
593 ("ê" "{\\\\^e}")
594 ("ï" "{\\\\\"\\\\i}")
595 ("ì" "{\\\\`\\\\i}")
596 ("í" "{\\\\'\\\\i}")
597 ("î" "{\\\\^\\\\i}")
598 ("ö" "\"o")
599 ("ò" "{\\\\`o}")
600 ("ó" "{\\\\'o}")
601 ("õ" "{\\\\~o}")
602 ("ô" "{\\\\^o}")
603 ("ü" "\"u")
604 ("ù" "{\\\\`u}")
605 ("ú" "{\\\\'u}")
606 ("û" "{\\\\^u}")
607 ("Ä" "\"A")
608 ("À" "{\\\\`A}")
609 ("Á" "{\\\\'A}")
610 ("Ã" "{\\\\~A}")
611 ("Â" "{\\\\^A}")
612 ("Ë" "{\\\\\"E}")
613 ("È" "{\\\\`E}")
614 ("É" "{\\\\'E}")
615 ("Ê" "{\\\\^E}")
616 ("Ï" "{\\\\\"I}")
617 ("Ì" "{\\\\`I}")
618 ("Í" "{\\\\'I}")
619 ("Î" "{\\\\^I}")
620 ("Ö" "\"O")
621 ("Ò" "{\\\\`O}")
622 ("Ó" "{\\\\'O}")
623 ("Õ" "{\\\\~O}")
624 ("Ô" "{\\\\^O}")
625 ("Ü" "\"U")
626 ("Ù" "{\\\\`U}")
627 ("Ú" "{\\\\'U}")
628 ("Û" "{\\\\^U}")
629 ("ñ" "{\\\\~n}")
630 ("Ñ" "{\\\\~N}")
631 ("ç" "{\\\\c c}")
632 ("Ç" "{\\\\c C}")
633 ("ß" "\"s")
634 ("\306" "{\\\\AE}")
635 ("\346" "{\\\\ae}")
636 ("\305" "{\\\\AA}")
637 ("\345" "{\\\\aa}")
638 ("\251" "{\\\\copyright}")
639 ("£" "{\\\\pounds}")
640 ("¶" "{\\\\P}")
641 ("§" "{\\\\S}")
642 ("¿" "{?`}")
643 ("¡" "{!`}")
645 "Translation table for translating ISO 8859-1 characters to German TeX.")
647 ;;;###autoload
648 (defun iso-gtex2iso (from to &optional buffer)
649 "Translate German TeX sequences to ISO 8859-1 characters.
650 The region between FROM and TO is translated using the table TRANS-TAB.
651 Optional arg BUFFER is ignored (for use in `format-alist')."
652 (interactive "*r")
653 (iso-translate-conventions from to iso-gtex2iso-trans-tab))
655 ;;;###autoload
656 (defun iso-iso2gtex (from to &optional buffer)
657 "Translate ISO 8859-1 characters to German TeX sequences.
658 The region between FROM and TO is translated using the table TRANS-TAB.
659 Optional arg BUFFER is ignored (for use in `format-alist')."
660 (interactive "*r")
661 (iso-translate-conventions from to iso-iso2gtex-trans-tab))
663 (defvar iso-iso2duden-trans-tab
664 '(("ä" "ae")
665 ("Ä" "Ae")
666 ("ö" "oe")
667 ("Ö" "Oe")
668 ("ü" "ue")
669 ("Ü" "Ue")
670 ("ß" "ss")))
672 ;;;###autoload
673 (defun iso-iso2duden (from to &optional buffer)
674 "Translate ISO 8859-1 characters to German TeX sequences.
675 The region between FROM and TO is translated using the table TRANS-TAB.
676 Optional arg BUFFER is ignored (for use in `format-alist')."
677 (interactive "*r")
678 (iso-translate-conventions from to iso-iso2duden-trans-tab))
680 (defvar iso-iso2sgml-trans-tab
681 '(("À" "&Agrave;")
682 ("Á" "&Aacute;")
683 ("Â" "&Acirc;")
684 ("Ã" "&Atilde;")
685 ("Ä" "&Auml;")
686 ("Å" "&Aring;")
687 ("Æ" "&AElig;")
688 ("Ç" "&Ccedil;")
689 ("È" "&Egrave;")
690 ("É" "&Eacute;")
691 ("Ê" "&Ecirc;")
692 ("Ë" "&Euml;")
693 ("Ì" "&Igrave;")
694 ("Í" "&Iacute;")
695 ("Î" "&Icirc;")
696 ("Ï" "&Iuml;")
697 ("Ð" "&ETH;")
698 ("Ñ" "&Ntilde;")
699 ("Ò" "&Ograve;")
700 ("Ó" "&Oacute;")
701 ("Ô" "&Ocirc;")
702 ("Õ" "&Otilde;")
703 ("Ö" "&Ouml;")
704 ("Ø" "&Oslash;")
705 ("Ù" "&Ugrave;")
706 ("Ú" "&Uacute;")
707 ("Û" "&Ucirc;")
708 ("Ü" "&Uuml;")
709 ("Ý" "&Yacute;")
710 ("Þ" "&THORN;")
711 ("ß" "&szlig;")
712 ("à" "&agrave;")
713 ("á" "&aacute;")
714 ("â" "&acirc;")
715 ("ã" "&atilde;")
716 ("ä" "&auml;")
717 ("å" "&aring;")
718 ("æ" "&aelig;")
719 ("ç" "&ccedil;")
720 ("è" "&egrave;")
721 ("é" "&eacute;")
722 ("ê" "&ecirc;")
723 ("ë" "&euml;")
724 ("ì" "&igrave;")
725 ("í" "&iacute;")
726 ("î" "&icirc;")
727 ("ï" "&iuml;")
728 ("ð" "&eth;")
729 ("ñ" "&ntilde;")
730 ("ò" "&ograve;")
731 ("ó" "&oacute;")
732 ("ô" "&ocirc;")
733 ("õ" "&otilde;")
734 ("ö" "&ouml;")
735 ("ø" "&oslash;")
736 ("ù" "&ugrave;")
737 ("ú" "&uacute;")
738 ("û" "&ucirc;")
739 ("ü" "&uuml;")
740 ("ý" "&yacute;")
741 ("þ" "&thorn;")
742 ("ÿ" "&yuml;")))
744 (defvar iso-sgml2iso-trans-tab
745 '(("&Agrave;" "À")
746 ("&Aacute;" "Á")
747 ("&Acirc;" "Â")
748 ("&Atilde;" "Ã")
749 ("&Auml;" "Ä")
750 ("&Aring;" "Å")
751 ("&AElig;" "Æ")
752 ("&Ccedil;" "Ç")
753 ("&Egrave;" "È")
754 ("&Eacute;" "É")
755 ("&Ecirc;" "Ê")
756 ("&Euml;" "Ë")
757 ("&Igrave;" "Ì")
758 ("&Iacute;" "Í")
759 ("&Icirc;" "Î")
760 ("&Iuml;" "Ï")
761 ("&ETH;" "Ð")
762 ("&Ntilde;" "Ñ")
763 ("&Ograve;" "Ò")
764 ("&Oacute;" "Ó")
765 ("&Ocirc;" "Ô")
766 ("&Otilde;" "Õ")
767 ("&Ouml;" "Ö")
768 ("&Oslash;" "Ø")
769 ("&Ugrave;" "Ù")
770 ("&Uacute;" "Ú")
771 ("&Ucirc;" "Û")
772 ("&Uuml;" "Ü")
773 ("&Yacute;" "Ý")
774 ("&THORN;" "Þ")
775 ("&szlig;" "ß")
776 ("&agrave;" "à")
777 ("&aacute;" "á")
778 ("&acirc;" "â")
779 ("&atilde;" "ã")
780 ("&auml;" "ä")
781 ("&aring;" "å")
782 ("&aelig;" "æ")
783 ("&ccedil;" "ç")
784 ("&egrave;" "è")
785 ("&eacute;" "é")
786 ("&ecirc;" "ê")
787 ("&euml;" "ë")
788 ("&igrave;" "ì")
789 ("&iacute;" "í")
790 ("&icirc;" "î")
791 ("&iuml;" "ï")
792 ("&eth;" "ð")
793 ("&ntilde;" "ñ")
794 ("&ograve;" "ò")
795 ("&oacute;" "ó")
796 ("&ocirc;" "ô")
797 ("&otilde;" "õ")
798 ("&ouml;" "ö")
799 ("&oslash;" "ø")
800 ("&ugrave;" "ù")
801 ("&uacute;" "ú")
802 ("&ucirc;" "û")
803 ("&uuml;" "ü")
804 ("&yacute;" "ý")
805 ("&thorn;" "þ")
806 ("&yuml;" "ÿ")))
808 ;;;###autoload
809 (defun iso-iso2sgml (from to &optional buffer)
810 "Translate ISO 8859-1 characters in the region to SGML entities.
811 The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
812 Optional arg BUFFER is ignored (for use in `format-alist')."
813 (interactive "*r")
814 (iso-translate-conventions from to iso-iso2sgml-trans-tab))
816 ;;;###autoload
817 (defun iso-sgml2iso (from to &optional buffer)
818 "Translate SGML entities in the region to ISO 8859-1 characters.
819 The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
820 Optional arg BUFFER is ignored (for use in `format-alist')."
821 (interactive "*r")
822 (iso-translate-conventions from to iso-sgml2iso-trans-tab))
824 ;;;###autoload
825 (defun iso-cvt-read-only ()
826 "Warn that format is read-only."
827 (interactive)
828 (error "This format is read-only; specify another format for writing"))
830 ;;;###autoload
831 (defun iso-cvt-write-only ()
832 "Warn that format is write-only."
833 (interactive)
834 (error "This format is write-only"))
836 ;;;###autoload
837 (defun iso-cvt-define-menu ()
838 "Add submenus to the File menu, to convert to and from various formats."
839 (interactive)
841 (let ((load-as-menu-map (make-sparse-keymap "Load As..."))
842 (insert-as-menu-map (make-sparse-keymap "Insert As..."))
843 (write-as-menu-map (make-sparse-keymap "Write As..."))
844 (translate-to-menu-map (make-sparse-keymap "Translate to..."))
845 (translate-from-menu-map (make-sparse-keymap "Translate from..."))
846 (menu menu-bar-file-menu))
848 (define-key menu [load-as-separator] '("--"))
850 (define-key menu [load-as] '("Load As..." . iso-cvt-load-as))
851 (fset 'iso-cvt-load-as load-as-menu-map)
853 ;;(define-key menu [insert-as] '("Insert As..." . iso-cvt-insert-as))
854 (fset 'iso-cvt-insert-as insert-as-menu-map)
856 (define-key menu [write-as] '("Write As..." . iso-cvt-write-as))
857 (fset 'iso-cvt-write-as write-as-menu-map)
859 (define-key menu [translate-separator] '("--"))
861 (define-key menu [translate-to] '("Translate to..." . iso-cvt-translate-to))
862 (fset 'iso-cvt-translate-to translate-to-menu-map)
864 (define-key menu [translate-from] '("Translate from..." . iso-cvt-translate-from))
865 (fset 'iso-cvt-translate-from translate-from-menu-map)
867 (dolist (file-type (reverse format-alist))
868 (let ((name (car file-type))
869 (str-name (cadr file-type)))
870 (if (stringp str-name)
871 (progn
872 (define-key load-as-menu-map (vector name)
873 (cons str-name
874 `(lambda (file)
875 (interactive ,(format "FFind file (as %s): " name))
876 (format-find-file file ',name))))
877 (define-key insert-as-menu-map (vector name)
878 (cons str-name
879 `(lambda (file)
880 (interactive (format "FInsert file (as %s): " ,name))
881 (format-insert-file file ',name))))
882 (define-key write-as-menu-map (vector name)
883 (cons str-name
884 `(lambda (file)
885 (interactive (format "FWrite file (as %s): " ,name))
886 (format-write-file file ',name))))
887 (define-key translate-to-menu-map (vector name)
888 (cons str-name
889 `(lambda ()
890 (interactive)
891 (format-encode-buffer ',name))))
892 (define-key translate-from-menu-map (vector name)
893 (cons str-name
894 `(lambda ()
895 (interactive)
896 (format-decode-buffer ',name))))))))))
898 (provide 'iso-cvt)
900 ;; arch-tag: 64ae843f-ed0e-43e1-ba50-ffd581b90840
901 ;;; iso-cvt.el ends here