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, 1997, 1998, 2000, 2001,
5;;   2002, 2003, 2004, 2005, 2006, 2007  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., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, 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.
87The region between FROM and TO is translated using the table TRANS-TAB.
88Optional 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.
104This table uses an aggressive translation approach and may erroneously
105translate 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.
119This table uses a conservative translation approach and may translate too
120little.")
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.
128The region between FROM and TO is translated using the table TRANS-TAB.
129Optional 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.
200The region between FROM and TO is translated using the table TRANS-TAB.
201Optional 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    ;; 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    ("!`" "�")
384    )
385  "Translation table for translating TeX sequences to ISO 8859-1 characters.
386This table is not exhaustive (and due to TeX's power can never be).  It only
387contains commonly used sequences.")
388
389;;;###autoload
390(defun iso-tex2iso (from to &optional buffer)
391 "Translate TeX sequences to ISO 8859-1 characters.
392The region between FROM and TO is translated using the table TRANS-TAB.
393Optional arg BUFFER is ignored (for use in `format-alist')."
394 (interactive "*r")
395 (iso-translate-conventions from to iso-tex2iso-trans-tab))
396
397(defvar iso-gtex2iso-trans-tab
398  '(
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" "�")
578    )
579  "Translation table for translating German TeX sequences to ISO 8859-1.
580This table is not exhaustive (and due to TeX's power can never be).  It only
581contains commonly used sequences.")
582
583(defvar iso-iso2gtex-trans-tab
584  '(
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    ("�" "{!`}")
644    )
645  "Translation table for translating ISO 8859-1 characters to German TeX.")
646
647;;;###autoload
648(defun iso-gtex2iso (from to &optional buffer)
649 "Translate German TeX sequences to ISO 8859-1 characters.
650The region between FROM and TO is translated using the table TRANS-TAB.
651Optional arg BUFFER is ignored (for use in `format-alist')."
652 (interactive "*r")
653 (iso-translate-conventions from to iso-gtex2iso-trans-tab))
654
655;;;###autoload
656(defun iso-iso2gtex (from to &optional buffer)
657 "Translate ISO 8859-1 characters to German TeX sequences.
658The region between FROM and TO is translated using the table TRANS-TAB.
659Optional arg BUFFER is ignored (for use in `format-alist')."
660 (interactive "*r")
661 (iso-translate-conventions from to iso-iso2gtex-trans-tab))
662
663(defvar iso-iso2duden-trans-tab
664  '(("�" "ae")
665    ("�" "Ae")
666    ("�" "oe")
667    ("�" "Oe")
668    ("�" "ue")
669    ("�" "Ue")
670    ("�" "ss")))
671
672;;;###autoload
673(defun iso-iso2duden (from to &optional buffer)
674 "Translate ISO 8859-1 characters to German TeX sequences.
675The region between FROM and TO is translated using the table TRANS-TAB.
676Optional arg BUFFER is ignored (for use in `format-alist')."
677 (interactive "*r")
678 (iso-translate-conventions from to iso-iso2duden-trans-tab))
679
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;")))
743
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    ("&nbsp;" "�")
795    ("&ograve;" "�")
796    ("&oacute;" "�")
797    ("&ocirc;" "�")
798    ("&otilde;" "�")
799    ("&ouml;" "�")
800    ("&oslash;" "�")
801    ("&ugrave;" "�")
802    ("&uacute;" "�")
803    ("&ucirc;" "�")
804    ("&uuml;" "�")
805    ("&yacute;" "�")
806    ("&thorn;" "�")
807    ("&yuml;" "�")))
808
809;;;###autoload
810(defun iso-iso2sgml (from to &optional buffer)
811 "Translate ISO 8859-1 characters in the region to SGML entities.
812The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
813Optional arg BUFFER is ignored (for use in `format-alist')."
814 (interactive "*r")
815 (iso-translate-conventions from to iso-iso2sgml-trans-tab))
816
817;;;###autoload
818(defun iso-sgml2iso (from to &optional buffer)
819 "Translate SGML entities in the region to ISO 8859-1 characters.
820The entities used are from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
821Optional arg BUFFER is ignored (for use in `format-alist')."
822 (interactive "*r")
823 (iso-translate-conventions from to iso-sgml2iso-trans-tab))
824
825;;;###autoload
826(defun iso-cvt-read-only (&rest ignore)
827  "Warn that format is read-only."
828  (interactive)
829  (error "This format is read-only; specify another format for writing"))
830
831;;;###autoload
832(defun iso-cvt-write-only (&rest ignore)
833  "Warn that format is write-only."
834  (interactive)
835  (error "This format is write-only"))
836
837;;;###autoload
838(defun iso-cvt-define-menu ()
839  "Add submenus to the File menu, to convert to and from various formats."
840  (interactive)
841
842  (let ((load-as-menu-map (make-sparse-keymap "Load As..."))
843	(insert-as-menu-map (make-sparse-keymap "Insert As..."))
844	(write-as-menu-map (make-sparse-keymap "Write As..."))
845	(translate-to-menu-map (make-sparse-keymap "Translate to..."))
846	(translate-from-menu-map (make-sparse-keymap "Translate from..."))
847	(menu menu-bar-file-menu))
848
849    (define-key menu [load-as-separator] '("--"))
850
851    (define-key menu [load-as] '("Load As..." . iso-cvt-load-as))
852    (fset 'iso-cvt-load-as load-as-menu-map)
853
854    ;;(define-key menu [insert-as] '("Insert As..." . iso-cvt-insert-as))
855    (fset 'iso-cvt-insert-as insert-as-menu-map)
856
857    (define-key menu [write-as] '("Write As..." . iso-cvt-write-as))
858    (fset 'iso-cvt-write-as write-as-menu-map)
859
860    (define-key menu [translate-separator] '("--"))
861
862    (define-key menu [translate-to] '("Translate to..." . iso-cvt-translate-to))
863    (fset 'iso-cvt-translate-to translate-to-menu-map)
864
865    (define-key menu [translate-from] '("Translate from..." . iso-cvt-translate-from))
866    (fset 'iso-cvt-translate-from translate-from-menu-map)
867
868    (dolist (file-type (reverse format-alist))
869      (let ((name (car file-type))
870	    (str-name (cadr file-type)))
871	(if (stringp str-name)
872	    (progn
873	      (define-key load-as-menu-map (vector name)
874		(cons str-name
875		      `(lambda (file)
876			 (interactive ,(format "FFind file (as %s): " name))
877			 (format-find-file file ',name))))
878	      (define-key insert-as-menu-map (vector name)
879		(cons str-name
880		      `(lambda (file)
881			 (interactive (format "FInsert file (as %s): " ,name))
882			 (format-insert-file file ',name))))
883	      (define-key write-as-menu-map (vector name)
884		(cons str-name
885		      `(lambda (file)
886			 (interactive (format "FWrite file (as %s): " ,name))
887			 (format-write-file file ',name))))
888	      (define-key translate-to-menu-map (vector name)
889		(cons str-name
890		      `(lambda ()
891			 (interactive)
892			 (format-encode-buffer ',name))))
893	      (define-key translate-from-menu-map (vector name)
894		(cons str-name
895		      `(lambda ()
896			 (interactive)
897			 (format-decode-buffer ',name))))))))))
898
899(provide 'iso-cvt)
900
901;; arch-tag: 64ae843f-ed0e-43e1-ba50-ffd581b90840
902;;; iso-cvt.el ends here
903