Prefer UTF-8 when the encoding shouldn't matter and changes are small.
[bpt/emacs.git] / lisp / international / iso-cvt.el
CommitLineData
c38e0c97 1;;; iso-cvt.el --- translate ISO 8859-1 from/to various encodings -*- coding: utf-8 -*-
be010748
RS
2;; This file was formerly called gm-lingo.el.
3
ab422c4d 4;; Copyright (C) 1993-1998, 2000-2013 Free Software Foundation, Inc.
d9375d2d
RS
5
6;; Author: Michael Gschwind <mike@vlsivie.tuwien.ac.at>
7;; Keywords: tex, iso, latin, i18n
8
9;; This file is part of GNU Emacs.
10
4936186e 11;; GNU Emacs is free software: you can redistribute it and/or modify
d9375d2d 12;; it under the terms of the GNU General Public License as published by
4936186e
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
d9375d2d
RS
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
4936186e 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
d9375d2d 23
575f522f
DL
24;;; Commentary:
25;; This lisp code is a general framework for translating various
48cd9fe9
RS
26;; representations of the same data.
27;; among other things it can be used to translate TeX, HTML, and compressed
575f522f 28;; files to ISO 8859-1. It can also be used to translate different charsets
48cd9fe9
RS
29;; such as IBM PC, Macintosh or HP Roman8.
30;; Note that many translations use the GNU recode tool to do the actual
31;; conversion. So you might want to install that tool to get the full
32;; benefit of iso-cvt.el
48cd9fe9
RS
33
34; TO DO:
6f52a61e 35; Cover more cases for translation. (There is an infinite number of ways to
48cd9fe9
RS
36; represent accented characters in TeX)
37
38;; SEE ALSO:
575f522f 39; If you are interested in questions related to using the ISO 8859-1
48cd9fe9 40; characters set (configuring emacs, Unix, etc. to use ISO), then you
575f522f 41; can get the ISO 8859-1 FAQ via anonymous ftp from
f1f6004b 42; ftp.vlsivie.tuwien.ac.at in /pub/8bit/FAQ-ISO-8859-1
d9375d2d
RS
43
44;;; Code:
45
d9375d2d
RS
46(defvar iso-spanish-trans-tab
47 '(
c38e0c97
PE
48 ("~n" "ñ")
49 ("\([a-zA-Z]\)#" "\\1ñ")
50 ("~N" "Ñ")
51 ("\\([-a-zA-Z\"`]\\)\"u" "\\1ü")
52 ("\\([-a-zA-Z\"`]\\)\"U" "\\1Ü")
53 ("\\([-a-zA-Z]\\)'o" "\\1ó")
54 ("\\([-a-zA-Z]\\)'O" "\\Ó")
55 ("\\([-a-zA-Z]\\)'e" "\\1é")
56 ("\\([-a-zA-Z]\\)'E" "\\1É")
57 ("\\([-a-zA-Z]\\)'a" "\\1á")
d9375d2d 58 ("\\([-a-zA-Z]\\)'A" "\\1A")
c38e0c97
PE
59 ("\\([-a-zA-Z]\\)'i" "\\1í")
60 ("\\([-a-zA-Z]\\)'I" "\\1Í")
d9375d2d
RS
61 )
62 "Spanish translation table.")
63
48cd9fe9 64(defun iso-translate-conventions (from to trans-tab)
3618423c 65 "Translate between FROM and TO using the translation table TRANS-TAB."
d9375d2d 66 (save-excursion
48cd9fe9
RS
67 (save-restriction
68 (narrow-to-region from to)
69 (goto-char from)
70 (let ((work-tab trans-tab)
71 (buffer-read-only nil)
72 (case-fold-search nil))
73 (while work-tab
74 (save-excursion
75 (let ((trans-this (car work-tab)))
76 (while (re-search-forward (car trans-this) nil t)
77 (replace-match (car (cdr trans-this)) t nil)))
78 (setq work-tab (cdr work-tab)))))
79 (point-max))))
80
575f522f
DL
81;;;###autoload
82(defun iso-spanish (from to &optional buffer)
83 "Translate net conventions for Spanish to ISO 8859-1.
3618423c
JB
84Translate the region between FROM and TO using the table
85`iso-spanish-trans-tab'.
c9669fac 86Optional arg BUFFER is ignored (for use in `format-alist')."
575f522f 87 (interactive "*r")
48cd9fe9 88 (iso-translate-conventions from to iso-spanish-trans-tab))
d9375d2d
RS
89
90(defvar iso-aggressive-german-trans-tab
91 '(
c38e0c97
PE
92 ("\"a" "ä")
93 ("\"A" "Ä")
94 ("\"o" "ö")
95 ("\"O" "Ö")
96 ("\"u" "ü")
97 ("\"U" "Ü")
98 ("\"s" "ß")
99 ("\\\\3" "ß")
d9375d2d 100 )
575f522f 101 "German translation table.
3618423c
JB
102This table uses an aggressive translation approach
103and may erroneously translate too much.")
d9375d2d
RS
104
105(defvar iso-conservative-german-trans-tab
106 '(
c38e0c97
PE
107 ("\\([-a-zA-Z\"`]\\)\"a" "\\1ä")
108 ("\\([-a-zA-Z\"`]\\)\"A" "\\1Ä")
109 ("\\([-a-zA-Z\"`]\\)\"o" "\\1ö")
110 ("\\([-a-zA-Z\"`]\\)\"O" "\\1Ö")
111 ("\\([-a-zA-Z\"`]\\)\"u" "\\1ü")
112 ("\\([-a-zA-Z\"`]\\)\"U" "\\1Ü")
113 ("\\([-a-zA-Z\"`]\\)\"s" "\\1ß")
114 ("\\([-a-zA-Z\"`]\\)\\\\3" "\\1ß")
d9375d2d
RS
115 )
116 "German translation table.
3618423c
JB
117This table uses a conservative translation approach
118and may translate too little.")
d9375d2d 119
575f522f 120(defvar iso-german-trans-tab iso-aggressive-german-trans-tab
d9375d2d
RS
121 "Currently active translation table for German.")
122
575f522f
DL
123;;;###autoload
124(defun iso-german (from to &optional buffer)
125 "Translate net conventions for German to ISO 8859-1.
3618423c
JB
126Translate the region FROM and TO using the table
127`iso-german-trans-tab'.
c9669fac 128Optional arg BUFFER is ignored (for use in `format-alist')."
575f522f 129 (interactive "*r")
48cd9fe9 130 (iso-translate-conventions from to iso-german-trans-tab))
a1506d29 131
d9375d2d
RS
132(defvar iso-iso2tex-trans-tab
133 '(
c38e0c97
PE
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}")
a2570ea9
RS
183 ("\306" "{\\\\AE}")
184 ("\346" "{\\\\ae}")
3a0e8467
RS
185 ("\305" "{\\\\AA}")
186 ("\345" "{\\\\aa}")
a2570ea9 187 ("\251" "{\\\\copyright}")
c38e0c97
PE
188 ("£" "{\\\\pounds}")
189 ("¶" "{\\\\P}")
190 ("§" "{\\\\S}")
191 ("¿" "{?`}")
192 ("¡" "{!`}")
d9375d2d
RS
193 )
194 "Translation table for translating ISO 8859-1 characters to TeX sequences.")
195
575f522f
DL
196;;;###autoload
197(defun iso-iso2tex (from to &optional buffer)
198 "Translate ISO 8859-1 characters to TeX sequences.
3618423c
JB
199Translate the region between FROM and TO using the table
200`iso-iso2tex-trans-tab'.
c9669fac 201Optional arg BUFFER is ignored (for use in `format-alist')."
575f522f 202 (interactive "*r")
48cd9fe9 203 (iso-translate-conventions from to iso-iso2tex-trans-tab))
d9375d2d 204
d9375d2d
RS
205(defvar iso-tex2iso-trans-tab
206 '(
c38e0c97
PE
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" "ê")
23140151
RS
268 ;; Discard spaces and/or one EOF after macro \i.
269 ;; Converting it back will use braces.
c38e0c97
PE
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}" "ß")
a2570ea9
RS
368 ("{\\\\AE}" "\306")
369 ("{\\\\ae}" "\346")
3a0e8467
RS
370 ("{\\\\AA}" "\305")
371 ("{\\\\aa}" "\345")
a2570ea9
RS
372 ("{\\\\copyright}" "\251")
373 ("\\\\copyright{}" "\251")
c38e0c97
PE
374 ("{\\\\pounds}" "£" )
375 ("{\\\\P}" "¶" )
376 ("{\\\\S}" "§" )
377 ("\\\\pounds{}" "£" )
378 ("\\\\P{}" "¶" )
379 ("\\\\S{}" "§" )
380 ("{\\?`}" "¿")
381 ("{!`}" "¡")
382 ("\\?`" "¿")
383 ("!`" "¡")
d9375d2d 384 )
575f522f 385 "Translation table for translating TeX sequences to ISO 8859-1 characters.
3618423c
JB
386This table is not exhaustive (and due to TeX's power can never be).
387It only contains commonly used sequences.")
d9375d2d 388
575f522f
DL
389;;;###autoload
390(defun iso-tex2iso (from to &optional buffer)
391 "Translate TeX sequences to ISO 8859-1 characters.
3618423c
JB
392Translate the region between FROM and TO using the table
393`iso-tex2iso-trans-tab'.
c9669fac 394Optional arg BUFFER is ignored (for use in `format-alist')."
575f522f 395 (interactive "*r")
48cd9fe9 396 (iso-translate-conventions from to iso-tex2iso-trans-tab))
d9375d2d
RS
397
398(defvar iso-gtex2iso-trans-tab
399 '(
c38e0c97
PE
400 ("{\\\\\"a}" "ä")
401 ("{\\\\`a}" "à")
402 ("{\\\\'a}" "á")
403 ("{\\\\~a}" "ã")
404 ("{\\\\^a}" "â")
405 ("{\\\\\"e}" "ë")
406 ("{\\\\`e}" "è")
407 ("{\\\\'e}" "é")
408 ("{\\\\^e}" "ê")
409 ("{\\\\\"\\\\i}" "ï")
410 ("{\\\\`\\\\i}" "ì")
411 ("{\\\\'\\\\i}" "í")
412 ("{\\\\^\\\\i}" "î")
413 ("{\\\\\"i}" "ï")
414 ("{\\\\`i}" "ì")
415 ("{\\\\'i}" "í")
416 ("{\\\\^i}" "î")
417 ("{\\\\\"o}" "ö")
418 ("{\\\\`o}" "ò")
419 ("{\\\\'o}" "ó")
420 ("{\\\\~o}" "õ")
421 ("{\\\\^o}" "ô")
422 ("{\\\\\"u}" "ü")
423 ("{\\\\`u}" "ù")
424 ("{\\\\'u}" "ú")
425 ("{\\\\^u}" "û")
426 ("{\\\\\"A}" "Ä")
427 ("{\\\\`A}" "À")
428 ("{\\\\'A}" "Á")
429 ("{\\\\~A}" "Ã")
430 ("{\\\\^A}" "Â")
431 ("{\\\\\"E}" "Ë")
432 ("{\\\\`E}" "È")
433 ("{\\\\'E}" "É")
434 ("{\\\\^E}" "Ê")
435 ("{\\\\\"I}" "Ï")
436 ("{\\\\`I}" "Ì")
437 ("{\\\\'I}" "Í")
438 ("{\\\\^I}" "Î")
439 ("{\\\\\"O}" "Ö")
440 ("{\\\\`O}" "Ò")
441 ("{\\\\'O}" "Ó")
442 ("{\\\\~O}" "Õ")
443 ("{\\\\^O}" "Ô")
444 ("{\\\\\"U}" "Ü")
445 ("{\\\\`U}" "Ù")
446 ("{\\\\'U}" "Ú")
447 ("{\\\\^U}" "Û")
448 ("{\\\\~n}" "ñ")
449 ("{\\\\~N}" "Ñ")
450 ("{\\\\c c}" "ç")
451 ("{\\\\c C}" "Ç")
452 ("\\\\\"a" "ä")
453 ("\\\\`a" "à")
454 ("\\\\'a" "á")
455 ("\\\\~a" "ã")
456 ("\\\\^a" "â")
457 ("\\\\\"e" "ë")
458 ("\\\\`e" "è")
459 ("\\\\'e" "é")
460 ("\\\\^e" "ê")
461 ("\\\\\"\\\\i" "ï")
462 ("\\\\`\\\\i" "ì")
463 ("\\\\'\\\\i" "í")
464 ("\\\\^\\\\i" "î")
465 ("\\\\\"i" "ï")
466 ("\\\\`i" "ì")
467 ("\\\\'i" "í")
468 ("\\\\^i" "î")
469 ("\\\\\"o" "ö")
470 ("\\\\`o" "ò")
471 ("\\\\'o" "ó")
472 ("\\\\~o" "õ")
473 ("\\\\^o" "ô")
474 ("\\\\\"u" "ü")
475 ("\\\\`u" "ù")
476 ("\\\\'u" "ú")
477 ("\\\\^u" "û")
478 ("\\\\\"A" "Ä")
479 ("\\\\`A" "À")
480 ("\\\\'A" "Á")
481 ("\\\\~A" "Ã")
482 ("\\\\^A" "Â")
483 ("\\\\\"E" "Ë")
484 ("\\\\`E" "È")
485 ("\\\\'E" "É")
486 ("\\\\^E" "Ê")
487 ("\\\\\"I" "Ï")
488 ("\\\\`I" "Ì")
489 ("\\\\'I" "Í")
490 ("\\\\^I" "Î")
491 ("\\\\\"O" "Ö")
492 ("\\\\`O" "Ò")
493 ("\\\\'O" "Ó")
494 ("\\\\~O" "Õ")
495 ("\\\\^O" "Ô")
496 ("\\\\\"U" "Ü")
497 ("\\\\`U" "Ù")
498 ("\\\\'U" "Ú")
499 ("\\\\^U" "Û")
500 ("\\\\~n" "ñ")
501 ("\\\\~N" "Ñ")
502 ("\\\\\"{a}" "ä")
503 ("\\\\`{a}" "à")
504 ("\\\\'{a}" "á")
505 ("\\\\~{a}" "ã")
506 ("\\\\^{a}" "â")
507 ("\\\\\"{e}" "ë")
508 ("\\\\`{e}" "è")
509 ("\\\\'{e}" "é")
510 ("\\\\^{e}" "ê")
511 ("\\\\\"{\\\\i}" "ï")
512 ("\\\\`{\\\\i}" "ì")
513 ("\\\\'{\\\\i}" "í")
514 ("\\\\^{\\\\i}" "î")
515 ("\\\\\"{i}" "ï")
516 ("\\\\`{i}" "ì")
517 ("\\\\'{i}" "í")
518 ("\\\\^{i}" "î")
519 ("\\\\\"{o}" "ö")
520 ("\\\\`{o}" "ò")
521 ("\\\\'{o}" "ó")
522 ("\\\\~{o}" "õ")
523 ("\\\\^{o}" "ô")
524 ("\\\\\"{u}" "ü")
525 ("\\\\`{u}" "ù")
526 ("\\\\'{u}" "ú")
527 ("\\\\^{u}" "û")
528 ("\\\\\"{A}" "Ä")
529 ("\\\\`{A}" "À")
530 ("\\\\'{A}" "Á")
531 ("\\\\~{A}" "Ã")
532 ("\\\\^{A}" "Â")
533 ("\\\\\"{E}" "Ë")
534 ("\\\\`{E}" "È")
535 ("\\\\'{E}" "É")
536 ("\\\\^{E}" "Ê")
537 ("\\\\\"{I}" "Ï")
538 ("\\\\`{I}" "Ì")
539 ("\\\\'{I}" "Í")
540 ("\\\\^{I}" "Î")
541 ("\\\\\"{O}" "Ö")
542 ("\\\\`{O}" "Ò")
543 ("\\\\'{O}" "Ó")
544 ("\\\\~{O}" "Õ")
545 ("\\\\^{O}" "Ô")
546 ("\\\\\"{U}" "Ü")
547 ("\\\\`{U}" "Ù")
548 ("\\\\'{U}" "Ú")
549 ("\\\\^{U}" "Û")
550 ("\\\\~{n}" "ñ")
551 ("\\\\~{N}" "Ñ")
552 ("\\\\c{c}" "ç")
553 ("\\\\c{C}" "Ç")
554 ("{\\\\ss}" "ß")
a2570ea9
RS
555 ("{\\\\AE}" "\306")
556 ("{\\\\ae}" "\346")
3a0e8467
RS
557 ("{\\\\AA}" "\305")
558 ("{\\\\aa}" "\345")
a2570ea9
RS
559 ("{\\\\copyright}" "\251")
560 ("\\\\copyright{}" "\251")
c38e0c97
PE
561 ("{\\\\pounds}" "£" )
562 ("{\\\\P}" "¶" )
563 ("{\\\\S}" "§" )
564 ("\\\\pounds{}" "£" )
565 ("\\\\P{}" "¶" )
566 ("\\\\S{}" "§" )
567 ("?`" "¿")
568 ("!`" "¡")
569 ("{?`}" "¿")
570 ("{!`}" "¡")
571 ("\"a" "ä")
572 ("\"A" "Ä")
573 ("\"o" "ö")
574 ("\"O" "Ö")
575 ("\"u" "ü")
576 ("\"U" "Ü")
577 ("\"s" "ß")
578 ("\\\\3" "ß")
d9375d2d
RS
579 )
580 "Translation table for translating German TeX sequences to ISO 8859-1.
3618423c
JB
581This table is not exhaustive (and due to TeX's power can never be).
582It only contains commonly used sequences.")
d9375d2d
RS
583
584(defvar iso-iso2gtex-trans-tab
585 '(
c38e0c97
PE
586 ("ä" "\"a")
587 ("à" "{\\\\`a}")
588 ("á" "{\\\\'a}")
589 ("ã" "{\\\\~a}")
590 ("â" "{\\\\^a}")
591 ("ë" "{\\\\\"e}")
592 ("è" "{\\\\`e}")
593 ("é" "{\\\\'e}")
594 ("ê" "{\\\\^e}")
595 ("ï" "{\\\\\"\\\\i}")
596 ("ì" "{\\\\`\\\\i}")
597 ("í" "{\\\\'\\\\i}")
598 ("î" "{\\\\^\\\\i}")
599 ("ö" "\"o")
600 ("ò" "{\\\\`o}")
601 ("ó" "{\\\\'o}")
602 ("õ" "{\\\\~o}")
603 ("ô" "{\\\\^o}")
604 ("ü" "\"u")
605 ("ù" "{\\\\`u}")
606 ("ú" "{\\\\'u}")
607 ("û" "{\\\\^u}")
608 ("Ä" "\"A")
609 ("À" "{\\\\`A}")
610 ("Á" "{\\\\'A}")
611 ("Ã" "{\\\\~A}")
612 ("Â" "{\\\\^A}")
613 ("Ë" "{\\\\\"E}")
614 ("È" "{\\\\`E}")
615 ("É" "{\\\\'E}")
616 ("Ê" "{\\\\^E}")
617 ("Ï" "{\\\\\"I}")
618 ("Ì" "{\\\\`I}")
619 ("Í" "{\\\\'I}")
620 ("Î" "{\\\\^I}")
621 ("Ö" "\"O")
622 ("Ò" "{\\\\`O}")
623 ("Ó" "{\\\\'O}")
624 ("Õ" "{\\\\~O}")
625 ("Ô" "{\\\\^O}")
626 ("Ü" "\"U")
627 ("Ù" "{\\\\`U}")
628 ("Ú" "{\\\\'U}")
629 ("Û" "{\\\\^U}")
630 ("ñ" "{\\\\~n}")
631 ("Ñ" "{\\\\~N}")
632 ("ç" "{\\\\c c}")
633 ("Ç" "{\\\\c C}")
634 ("ß" "\"s")
a2570ea9
RS
635 ("\306" "{\\\\AE}")
636 ("\346" "{\\\\ae}")
3a0e8467
RS
637 ("\305" "{\\\\AA}")
638 ("\345" "{\\\\aa}")
a2570ea9 639 ("\251" "{\\\\copyright}")
c38e0c97
PE
640 ("£" "{\\\\pounds}")
641 ("¶" "{\\\\P}")
642 ("§" "{\\\\S}")
643 ("¿" "{?`}")
644 ("¡" "{!`}")
d9375d2d
RS
645 )
646 "Translation table for translating ISO 8859-1 characters to German TeX.")
647
575f522f
DL
648;;;###autoload
649(defun iso-gtex2iso (from to &optional buffer)
650 "Translate German TeX sequences to ISO 8859-1 characters.
3618423c
JB
651Translate the region between FROM and TO using the table
652`iso-gtex2iso-trans-tab'.
c9669fac 653Optional arg BUFFER is ignored (for use in `format-alist')."
575f522f 654 (interactive "*r")
48cd9fe9 655 (iso-translate-conventions from to iso-gtex2iso-trans-tab))
d9375d2d 656
575f522f
DL
657;;;###autoload
658(defun iso-iso2gtex (from to &optional buffer)
659 "Translate ISO 8859-1 characters to German TeX sequences.
3618423c
JB
660Translate the region between FROM and TO using the table
661`iso-iso2gtex-trans-tab'.
c9669fac 662Optional arg BUFFER is ignored (for use in `format-alist')."
575f522f 663 (interactive "*r")
48cd9fe9
RS
664 (iso-translate-conventions from to iso-iso2gtex-trans-tab))
665
666(defvar iso-iso2duden-trans-tab
c38e0c97
PE
667 '(("ä" "ae")
668 ("Ä" "Ae")
669 ("ö" "oe")
670 ("Ö" "Oe")
671 ("ü" "ue")
672 ("Ü" "Ue")
673 ("ß" "ss"))
04690896 674 "Translation table for translating ISO 8859-1 characters to Duden sequences.")
48cd9fe9 675
575f522f
DL
676;;;###autoload
677(defun iso-iso2duden (from to &optional buffer)
04690896 678 "Translate ISO 8859-1 characters to Duden sequences.
3618423c
JB
679Translate the region between FROM and TO using the table
680`iso-iso2duden-trans-tab'.
c9669fac 681Optional arg BUFFER is ignored (for use in `format-alist')."
575f522f 682 (interactive "*r")
48cd9fe9
RS
683 (iso-translate-conventions from to iso-iso2duden-trans-tab))
684
6f52a61e 685(defvar iso-iso2sgml-trans-tab
c38e0c97
PE
686 '(("À" "&Agrave;")
687 ("Á" "&Aacute;")
688 ("Â" "&Acirc;")
689 ("Ã" "&Atilde;")
690 ("Ä" "&Auml;")
691 ("Å" "&Aring;")
692 ("Æ" "&AElig;")
693 ("Ç" "&Ccedil;")
694 ("È" "&Egrave;")
695 ("É" "&Eacute;")
696 ("Ê" "&Ecirc;")
697 ("Ë" "&Euml;")
698 ("Ì" "&Igrave;")
699 ("Í" "&Iacute;")
700 ("Î" "&Icirc;")
701 ("Ï" "&Iuml;")
702 ("Ð" "&ETH;")
703 ("Ñ" "&Ntilde;")
704 ("Ò" "&Ograve;")
705 ("Ó" "&Oacute;")
706 ("Ô" "&Ocirc;")
707 ("Õ" "&Otilde;")
708 ("Ö" "&Ouml;")
709 ("Ø" "&Oslash;")
710 ("Ù" "&Ugrave;")
711 ("Ú" "&Uacute;")
712 ("Û" "&Ucirc;")
713 ("Ü" "&Uuml;")
714 ("Ý" "&Yacute;")
715 ("Þ" "&THORN;")
716 ("ß" "&szlig;")
717 ("à" "&agrave;")
718 ("á" "&aacute;")
719 ("â" "&acirc;")
720 ("ã" "&atilde;")
721 ("ä" "&auml;")
722 ("å" "&aring;")
723 ("æ" "&aelig;")
724 ("ç" "&ccedil;")
725 ("è" "&egrave;")
726 ("é" "&eacute;")
727 ("ê" "&ecirc;")
728 ("ë" "&euml;")
729 ("ì" "&igrave;")
730 ("í" "&iacute;")
731 ("î" "&icirc;")
732 ("ï" "&iuml;")
733 ("ð" "&eth;")
734 ("ñ" "&ntilde;")
735 ("ò" "&ograve;")
736 ("ó" "&oacute;")
737 ("ô" "&ocirc;")
738 ("õ" "&otilde;")
739 ("ö" "&ouml;")
740 ("ø" "&oslash;")
741 ("ù" "&ugrave;")
742 ("ú" "&uacute;")
743 ("û" "&ucirc;")
744 ("ü" "&uuml;")
745 ("ý" "&yacute;")
746 ("þ" "&thorn;")
747 ("ÿ" "&yuml;")))
6f52a61e
DL
748
749(defvar iso-sgml2iso-trans-tab
c38e0c97
PE
750 '(("&Agrave;" "À")
751 ("&Aacute;" "Á")
752 ("&Acirc;" "Â")
753 ("&Atilde;" "Ã")
754 ("&Auml;" "Ä")
755 ("&Aring;" "Å")
756 ("&AElig;" "Æ")
757 ("&Ccedil;" "Ç")
758 ("&Egrave;" "È")
759 ("&Eacute;" "É")
760 ("&Ecirc;" "Ê")
761 ("&Euml;" "Ë")
762 ("&Igrave;" "Ì")
763 ("&Iacute;" "Í")
764 ("&Icirc;" "Î")
765 ("&Iuml;" "Ï")
766 ("&ETH;" "Ð")
767 ("&Ntilde;" "Ñ")
768 ("&Ograve;" "Ò")
769 ("&Oacute;" "Ó")
770 ("&Ocirc;" "Ô")
771 ("&Otilde;" "Õ")
772 ("&Ouml;" "Ö")
773 ("&Oslash;" "Ø")
774 ("&Ugrave;" "Ù")
775 ("&Uacute;" "Ú")
776 ("&Ucirc;" "Û")
777 ("&Uuml;" "Ü")
778 ("&Yacute;" "Ý")
779 ("&THORN;" "Þ")
780 ("&szlig;" "ß")
781 ("&agrave;" "à")
782 ("&aacute;" "á")
783 ("&acirc;" "â")
784 ("&atilde;" "ã")
785 ("&auml;" "ä")
786 ("&aring;" "å")
787 ("&aelig;" "æ")
788 ("&ccedil;" "ç")
789 ("&egrave;" "è")
790 ("&eacute;" "é")
791 ("&ecirc;" "ê")
792 ("&euml;" "ë")
793 ("&igrave;" "ì")
794 ("&iacute;" "í")
795 ("&icirc;" "î")
796 ("&iuml;" "ï")
797 ("&eth;" "ð")
798 ("&ntilde;" "ñ")
799 ("&nbsp;" " ")
800 ("&ograve;" "ò")
801 ("&oacute;" "ó")
802 ("&ocirc;" "ô")
803 ("&otilde;" "õ")
804 ("&ouml;" "ö")
805 ("&oslash;" "ø")
806 ("&ugrave;" "ù")
807 ("&uacute;" "ú")
808 ("&ucirc;" "û")
809 ("&uuml;" "ü")
810 ("&yacute;" "ý")
811 ("&thorn;" "þ")
812 ("&yuml;" "ÿ")))
6f52a61e
DL
813
814;;;###autoload
815(defun iso-iso2sgml (from to &optional buffer)
816 "Translate ISO 8859-1 characters in the region to SGML entities.
3618423c 817Use entities from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
c9669fac 818Optional arg BUFFER is ignored (for use in `format-alist')."
6f52a61e
DL
819 (interactive "*r")
820 (iso-translate-conventions from to iso-iso2sgml-trans-tab))
821
822;;;###autoload
823(defun iso-sgml2iso (from to &optional buffer)
824 "Translate SGML entities in the region to ISO 8859-1 characters.
3618423c 825Use entities from \"ISO 8879:1986//ENTITIES Added Latin 1//EN\".
c9669fac 826Optional arg BUFFER is ignored (for use in `format-alist')."
6f52a61e
DL
827 (interactive "*r")
828 (iso-translate-conventions from to iso-sgml2iso-trans-tab))
829
575f522f 830;;;###autoload
4fb4bdcf 831(defun iso-cvt-read-only (&rest ignore)
575f522f 832 "Warn that format is read-only."
48cd9fe9
RS
833 (interactive)
834 (error "This format is read-only; specify another format for writing"))
835
575f522f 836;;;###autoload
4fb4bdcf 837(defun iso-cvt-write-only (&rest ignore)
575f522f 838 "Warn that format is write-only."
48cd9fe9
RS
839 (interactive)
840 (error "This format is write-only"))
a1506d29 841
575f522f 842;;;###autoload
48cd9fe9 843(defun iso-cvt-define-menu ()
202a3a71 844 "Add submenus to the File menu, to convert to and from various formats."
48cd9fe9
RS
845 (interactive)
846
7c782c24
SM
847 (let ((load-as-menu-map (make-sparse-keymap "Load As..."))
848 (insert-as-menu-map (make-sparse-keymap "Insert As..."))
849 (write-as-menu-map (make-sparse-keymap "Write As..."))
850 (translate-to-menu-map (make-sparse-keymap "Translate to..."))
851 (translate-from-menu-map (make-sparse-keymap "Translate from..."))
852 (menu menu-bar-file-menu))
04690896 853
7c782c24
SM
854 (define-key menu [load-as-separator] '("--"))
855
856 (define-key menu [load-as] '("Load As..." . iso-cvt-load-as))
857 (fset 'iso-cvt-load-as load-as-menu-map)
858
859 ;;(define-key menu [insert-as] '("Insert As..." . iso-cvt-insert-as))
860 (fset 'iso-cvt-insert-as insert-as-menu-map)
861
862 (define-key menu [write-as] '("Write As..." . iso-cvt-write-as))
863 (fset 'iso-cvt-write-as write-as-menu-map)
864
865 (define-key menu [translate-separator] '("--"))
866
867 (define-key menu [translate-to] '("Translate to..." . iso-cvt-translate-to))
868 (fset 'iso-cvt-translate-to translate-to-menu-map)
869
870 (define-key menu [translate-from] '("Translate from..." . iso-cvt-translate-from))
871 (fset 'iso-cvt-translate-from translate-from-menu-map)
872
1885cb88 873 (dolist (file-type (reverse format-alist))
7c782c24
SM
874 (let ((name (car file-type))
875 (str-name (cadr file-type)))
876 (if (stringp str-name)
877 (progn
878 (define-key load-as-menu-map (vector name)
879 (cons str-name
880 `(lambda (file)
881 (interactive ,(format "FFind file (as %s): " name))
882 (format-find-file file ',name))))
883 (define-key insert-as-menu-map (vector name)
884 (cons str-name
885 `(lambda (file)
886 (interactive (format "FInsert file (as %s): " ,name))
887 (format-insert-file file ',name))))
888 (define-key write-as-menu-map (vector name)
889 (cons str-name
890 `(lambda (file)
891 (interactive (format "FWrite file (as %s): " ,name))
892 (format-write-file file ',name))))
893 (define-key translate-to-menu-map (vector name)
894 (cons str-name
895 `(lambda ()
896 (interactive)
897 (format-encode-buffer ',name))))
898 (define-key translate-from-menu-map (vector name)
899 (cons str-name
900 `(lambda ()
901 (interactive)
902 (format-decode-buffer ',name))))))))))
6f52a61e
DL
903
904(provide 'iso-cvt)
d9375d2d
RS
905
906;;; iso-cvt.el ends here