annotate lisp/international/codepage.el @ 24086:bedce7fcf0f4

(ps-mule-font-info-database-bdf): Add alternative file names that avoid clashes in DOS 8+3 namespace. FONT-NAME can now be a list of alternative names. (ps-mule-generate-font): If FONT-NAME is a cons cell, use its car. (ps-mule-prepare-font): Likewise.
author Eli Zaretskii <eliz@gnu.org>
date Sun, 17 Jan 1999 16:32:50 +0000
parents 8dc3b068c0db
children bb95d3d24ff9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1 ;;; codepage.el --- MS-DOS specific coding systems.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
4
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
5 ;; Author: Eli Zaretskii
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
6 ;; Maintainer: FSF
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
7 ;; Keywords: i18n ms-dos codepage
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
14 ;; any later version.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
20
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28 ;; Special coding systems for DOS codepage support.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
29 ;;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30 ;; These coding systems perform conversion from the DOS codepage encoding
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 ;; to one of the ISO-8859 character sets. Each codepage has its corresponding
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32 ;; ISO-8859 charset, chosen so as to be able to convert all (or most) of the
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33 ;; characters. The idea is that Emacs internally works with the usual MULE
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 ;; charsets, and the conversion to and from the DOS codepage is performed
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35 ;; on I/O only.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36 ;; See term/internal.el for the complementary setup of the DOS terminal
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37 ;; display and input methods.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38 ;;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
39 ;; Thanks to Ken'ichi Handa <handa@etl.go.jp> for writing the CCL
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40 ;; encoders/decoders, and for help in debugging this code.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 ;;; Code:
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
44 (defun cp-coding-system-for-codepage-1 (coding mnemonic iso-name
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
45 decoder encoder)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
46 "Make coding system CODING for a DOS codepage using translation tables.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
47 MNEMONIC is a character to be displayed on mode line for the coding system.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
48 ISO-NAME is the name of the ISO-8859 charset which corresponds to this
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
49 codepage.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
50 DECODER is a translation table for converting characters in the DOS codepage
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
51 encoding to Emacs multibyte characters.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
52 ENCODER is a translation table for encoding Emacs multibyte characters into
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
53 external DOS codepage codes.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
54
23920
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
55 Note that the coding systems created by this function support automatic
23952
4ef8ec98dd43 (cp-make-coding-systems-for-codepage): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 23920
diff changeset
56 detection of the EOL format. However, the decoders and encoders created
4ef8ec98dd43 (cp-make-coding-systems-for-codepage): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 23920
diff changeset
57 for these coding systems only support DOS and Unix style EOLs (the -mac
4ef8ec98dd43 (cp-make-coding-systems-for-codepage): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 23920
diff changeset
58 variety is actually just an alias for the -unix variety)."
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
59 (save-match-data
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
60 (let* ((coding-name (symbol-name coding))
23920
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
61 (ccl-decoder-dos
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
62 (ccl-compile
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
63 `(4 (loop (read r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
64 (if (r1 != ?\r)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
65 (if (r1 >= 128)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
66 ((r0 = ,(charset-id 'ascii))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
67 (translate-character ,decoder r0 r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
68 (if (r0 == ,(charset-id 'ascii))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
69 (write r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
70 (write-multibyte-character r0 r1)))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
71 (write r1)))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
72 (repeat)))))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
73 (ccl-decoder-unix
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
74 (ccl-compile
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
75 `(4 (loop (read r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
76 (if (r1 >= 128)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
77 ((r0 = ,(charset-id 'ascii))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
78 (translate-character ,decoder r0 r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
79 (if (r0 == ,(charset-id 'ascii))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
80 (write r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
81 (write-multibyte-character r0 r1)))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
82 (write r1))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
83 (repeat)))))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
84 (ccl-encoder-dos
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
85 (ccl-compile
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
86 `(1 (loop (read-multibyte-character r0 r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
87 (if (r1 == ?\n)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
88 (write ?\r)
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 (if (r0 != ,(charset-id 'ascii))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 ((translate-character ,encoder r0 r1)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 (if (r0 == ,(charset-id 'japanese-jisx0208))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92 ((r1 = ??)
23920
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
93 (write r1))))))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
94 (write-repeat r1)))))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
95 (ccl-encoder-unix
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
96 (ccl-compile
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
97 `(1 (loop (read-multibyte-character r0 r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
98 (if (r0 != ,(charset-id 'ascii))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
99 ((translate-character ,encoder r0 r1)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
100 (if (r0 == ,(charset-id 'japanese-jisx0208))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
101 ((r1 = ??)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
102 (write r1)))))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
103 (write-repeat r1))))))
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
104 (if (memq coding coding-system-list)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
105 (setq coding-system-list (delq coding coding-system-list)))
23920
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
106
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
107 ;; Make coding system CODING.
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
108 (make-coding-system
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 coding 4 mnemonic
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 (concat "8-bit encoding of " (symbol-name iso-name)
23920
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
111 " characters using IBM codepage " coding-name)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
112 (cons ccl-decoder-unix ccl-encoder-unix)
24009
d026025237b5 (cp-coding-system-for-codepage-1): Add the valid-codes property.
Eli Zaretskii <eliz@gnu.org>
parents: 23952
diff changeset
113 `((safe-charsets ascii ,iso-name)
d026025237b5 (cp-coding-system-for-codepage-1): Add the valid-codes property.
Eli Zaretskii <eliz@gnu.org>
parents: 23952
diff changeset
114 (valid-codes (0 . 255))))
23920
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
115 ;;; Make coding systems CODING-unix, CODING-dos, CODING-mac.
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
116 (make-subsidiary-coding-system coding)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
117 (put coding 'eol-type (vector (intern (format "%s-unix" coding))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
118 (intern (format "%s-dos" coding))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
119 (intern (format "%s-mac" coding))))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
120 ;; Change CCL code for CODING-dos.
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
121 (let ((coding-spec (copy-sequence (get coding 'coding-system))))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
122 (aset coding-spec 4
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
123 (cons (check-ccl-program
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
124 ccl-decoder-dos
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
125 (intern (format "%s-dos-decoder" coding)))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
126 (check-ccl-program
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
127 ccl-encoder-dos
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
128 (intern (format "%s-dos-encoder" coding)))))
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
129 (put (intern (concat coding-name "-dos")) 'coding-system
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
130 coding-spec)))))
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 (defun cp-decoding-vector-for-codepage (table charset offset)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 "Create a vector for decoding IBM PC characters using conversion table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 TABLE into an ISO-8859 character set CHARSET whose first non-ASCII
24033
a5d31e58291b (codepage-setup): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 24009
diff changeset
135 character is generated by (make-char CHARSET OFFSET)."
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136 (let* ((len (length table))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 (undefined-char
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 (if (eq system-type 'ms-dos)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 (if dos-unsupported-char-glyph
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 (logand dos-unsupported-char-glyph 255)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141 127)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 32))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 (vec1 (make-vector 256 undefined-char))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144 (i 0))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145 (while (< i offset)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 (aset vec1 i i)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 (setq i (1+ i)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148 (setq i 0)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (while (< i len)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 (if (aref table i)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
151 (aset vec1 (aref table i) (make-char charset (+ i offset))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152 (setq i (1+ i)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 vec1))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 ;;; You don't think I created all these tables below by hand, do you?
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156 ;;; The following Awk script will create the table for cp850-to-Latin-1
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
157 ;;; conversion from the RFC 1345 file (the other tables are left as an
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 ;;; excercise):
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159 ;;; BEGIN { n_pages = 11;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 ;;; pn["IBM437"] = 0; pn["IBM850"] = 1; pn["IBM851"] = 2;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
161 ;;; pn["IBM852"] = 3; pn["IBM855"] = 4; pn["IBM860"] = 5;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162 ;;; pn["IBM861"] = 6; pn["IBM862"] = 7; pn["IBM863"] = 8;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
163 ;;; pn["IBM864"] = 9; pn["IBM865"] = 10;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164 ;;; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 ;;; $1 == "&charset" { charset = $2; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 ;;; $1 == "&code" { code = $2; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167 ;;; /^ [^&]/ {
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168 ;;; if ((charset ~ /^IBM(437|8(5[0125]|6[0-5]))$/) || (charset ~ /^ISO_8859-1/))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
169 ;;; {
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170 ;;; for (i = 1; i <= NF; i++)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171 ;;; chars[charset,code++] = $i;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
172 ;;; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173 ;;; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
174 ;;;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
175 ;;; END {
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176 ;;; for (i = 160; i < 256; i++)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 ;;; {
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 ;;; c = chars["ISO_8859-1:1987",i];
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
179 ;;; if (c == "??") # skip unused positions
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
180 ;;; {
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
181 ;;; printf " nil";
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 ;;; if ((i - 159)%16 == 0)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 ;;; printf "\n";
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184 ;;; continue;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185 ;;; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
186 ;;; found = 0;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 ;;; for (j in pn)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188 ;;; map[j] = "nil";
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189 ;;; for (combined in chars)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190 ;;; {
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
191 ;;; candidate = chars[combined];
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192 ;;; split (combined, separate, SUBSEP);
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 ;;; if (separate[1] == "IBM850" && candidate == c)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194 ;;; {
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
195 ;;; found = 1;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196 ;;; map[separate[1]] = separate[2];
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
197 ;;; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
198 ;;; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
199 ;;; printf " %s", map["IBM850"];
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
200 ;;; if ((i - 159)%16 == 0)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
201 ;;; printf "\n";
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
202 ;;; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203 ;;; }
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
204
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
205 ;;; WARNING WARNING WARNING!!!
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
206 ;;;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
207 ;;; If you want to get fancy with these tables, remember that the inverse
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
208 ;;; tables, created by `cp-decoding-vector-for-codepage' above, are installed
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
209 ;;; on MS-DOS as nonascii-translation-table (see `dos-codepage-setup' on
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
210 ;;; internal.el). Therefore, you should NOT put any codes below 128 in
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
211 ;;; these tables! Otherwise, various Emacs commands and functions will
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
212 ;;; mysteriously fail! For example, a typical screwup is to map the Latin-N
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
213 ;;; acute accent character to the apostrophe, and have all regexps which
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
214 ;;; end with "\\'" begin to fail (e.g., the automatic setting of the major
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
215 ;;; mode by file name extension will stop working).
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
216 ;;;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
217 ;;; You HAVE BEEN warned!
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
218
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
219 ;; US/English/PC-8/IBM-2. This doesn't support Latin-1 characters very
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
220 ;; well, but why not use what we can salvage?
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
221 (defvar cp437-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
222 ;; Nth element is the code of a cp437 glyph for the multibyte
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
223 ;; character created by (make-char 'latin-iso8859-1 (+ N 160)).
24064
e4cc744bdce5 (cp850-decode-table): Replace nil
Eli Zaretskii <eliz@gnu.org>
parents: 24033
diff changeset
224 ;; The element nil means there's no corresponding cp437 glyph.
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
225 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
226 255 173 155 156 nil 157 179 nil nil nil 166 174 170 196 nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
227 248 241 253 nil nil nil nil 249 nil nil 167 175 172 171 nil 168
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
228 nil nil nil nil 142 143 146 128 nil 144 nil nil nil nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
229 nil 165 nil nil nil nil 153 nil nil nil nil nil 154 nil nil 225
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
230 133 160 131 nil 132 134 145 135 138 130 136 137 141 161 140 139
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
231 nil 164 149 162 147 nil 148 246 nil 151 163 150 129 nil nil 152]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
232 "Table for converting ISO-8859-1 characters into codepage 437 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
233 (setplist 'cp437-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
234 '(charset latin-iso8859-1 language "Latin-1" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
235
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
236 ;; Multilingual (Latin-1)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
237 (defvar cp850-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
238 ;; Nth element is the code of a cp850 glyph for the multibyte
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
239 ;; character created by (make-char 'latin-iso8859-1 (+ N 160)).
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
240 ;; The element nil means there's no corresponding cp850 glyph.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
241 [
24072
749d25833f30 (cp850-decode-table): Fix previous change.
Eli Zaretskii <eliz@gnu.org>
parents: 24064
diff changeset
242 255 173 189 156 207 190 221 245 249 184 166 174 170 240 169 nil
24085
8dc3b068c0db (cp855-decode-table, cp850-decode-table): Fill some nil entries.
Eli Zaretskii <eliz@gnu.org>
parents: 24072
diff changeset
243 248 241 253 252 239 230 244 250 247 251 167 175 172 171 243 168
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
244 183 181 182 199 142 143 146 128 212 144 210 211 222 214 215 216
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
245 209 165 227 224 226 229 153 158 157 235 233 234 154 237 231 225
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
246 133 160 131 198 132 134 145 135 138 130 136 137 141 161 140 139
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
247 208 164 149 162 147 228 148 246 155 151 163 150 129 236 232 152]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
248 "Table for converting ISO-8859-1 characters into codepage 850 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
249 (setplist 'cp850-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
250 '(charset latin-iso8859-1 language "Latin-1" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
251
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
252 ;; Greek
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
253 (defvar cp851-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
254 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
255 255 nil nil 156 nil nil nil 245 249 nil nil 174 nil 240 nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
256 248 241 nil nil 239 nil 134 nil 141 143 144 175 146 171 149 152
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
257 161 164 165 166 167 168 169 170 172 173 181 182 184 183 189 190
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
258 198 199 nil 207 208 209 210 211 212 213 nil nil 155 157 158 159
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
259 252 214 215 216 221 222 224 225 226 227 228 229 230 231 232 233
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
260 234 235 237 236 238 242 243 244 246 250 160 251 162 163 253 nil]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
261 "Table for converting ISO-8859-7 characters into codepage 851 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
262 (setplist 'cp851-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
263 '(charset greek-iso8859-7 language "Greek" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
264
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
265 ;; Slavic/Eastern Europe (Latin-2)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266 (defvar cp852-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
267 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
268 255 164 244 157 207 149 151 245 249 230 184 155 141 240 166 189
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
269 248 165 247 136 239 150 152 243 242 231 173 156 171 241 167 190
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
270 232 181 182 198 142 145 143 128 172 144 168 211 183 214 nil 210
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
271 209 227 213 224 226 138 153 158 252 222 233 235 154 237 221 225
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
272 234 160 131 199 132 146 134 135 159 130 169 137 216 161 140 212
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273 208 228 229 162 147 139 148 246 253 133 163 251 129 236 238 250]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 "Table for converting ISO-8859-2 characters into codepage 852 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
275 (setplist 'cp852-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
276 '(charset latin-iso8859-2 language "Latin-2" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
277
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
278 ;; Russian
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
279 (defvar cp855-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
280 [
24085
8dc3b068c0db (cp855-decode-table, cp850-decode-table): Fill some nil entries.
Eli Zaretskii <eliz@gnu.org>
parents: 24072
diff changeset
281 255 133 129 131 135 137 139 141 143 145 147 149 151 240 153 155
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
282 161 163 236 173 167 169 234 244 184 190 199 209 211 213 215 221
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
283 226 228 230 232 171 182 165 252 246 250 159 242 238 248 157 224
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
284 160 162 235 172 166 168 233 243 183 189 198 208 210 212 214 216
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
285 225 227 229 231 170 181 164 251 245 249 158 241 237 247 156 222
24085
8dc3b068c0db (cp855-decode-table, cp850-decode-table): Fill some nil entries.
Eli Zaretskii <eliz@gnu.org>
parents: 24072
diff changeset
286 239 132 128 130 134 136 138 140 142 144 146 148 150 253 152 154]
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
287 "Table for converting ISO-8859-5 characters into codepage 855 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
288 (setplist 'cp855-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
289 '(charset cyrillic-iso8859-5 language "Cyrillic-ISO" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
290
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
291 ;; Turkish
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
292 (defvar cp857-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
294 255 nil nil 156 207 nil 245 249 152 158 166 nil 240 nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
295 248 nil 253 252 239 nil nil nil nil 141 159 167 nil 171 nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
296 183 181 182 142 nil nil 128 212 144 210 211 222 214 215 216
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
297 165 227 224 226 nil 153 232 nil 235 233 234 154 nil nil 225
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
298 133 160 131 132 nil nil 135 138 130 136 137 236 161 140 139
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
299 164 149 162 147 nil 148 246 nil 151 163 150 129 nil nil 250]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
300 "Table for converting ISO-8859-3 characters into codepage 857 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
301 (setplist 'cp857-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
302 '(charset latin-iso8859-3 language "Latin-3" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
303
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
304 ;; Portuguese
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
305 (defvar cp860-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
306 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
307 255 173 155 156 nil nil 179 nil nil nil 166 174 170 nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308 nil 241 253 nil nil nil nil 249 nil nil 167 175 172 171 nil 168
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
309 145 134 143 142 nil nil nil 128 146 144 137 nil 152 nil 139 nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
310 nil 165 159 169 140 153 nil nil nil 157 150 nil 154 nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
311 133 160 131 132 nil nil nil 135 138 130 136 nil 141 161 nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
312 nil 164 149 162 147 148 nil 246 nil 151 163 nil 129 nil nil nil]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
313 "Table for converting ISO-8859-1 characters into codepage 860 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
314 (setplist 'cp860-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
315 '(charset latin-iso8859-1 language "Latin-1" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
316
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
317 ;; Icelandic
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
318 (defvar cp861-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
319 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
320 255 173 nil 156 nil nil nil nil nil nil nil 174 170 nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
321 nil 241 253 nil nil nil nil 249 nil nil nil 175 172 171 nil 168
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
322 nil 164 nil nil 142 143 146 128 nil 144 nil nil nil 165 nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
323 139 nil 159 166 nil nil 153 nil 157 nil 167 nil 154 151 141 nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
324 133 160 131 nil 132 134 145 135 138 130 136 137 nil 161 nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
325 140 nil nil 162 147 nil 148 246 155 nil 163 150 129 152 149 nil]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
326 "Table for converting ISO-8859-1 characters into codepage 861 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
327 (setplist 'cp861-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
328 '(charset latin-iso8859-1 language "Latin-1" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
329
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
330 ;; Hebrew
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
331 (defvar cp862-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
332 ;; Nth element is the code of a cp862 glyph for the multibyte
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
333 ;; character created by (make-char 'hebrew-iso8859-8 (+ N 160)).
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
334 ;; The element nil means there's no corresponding cp850 glyph.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
335 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
336 255 173 155 156 nil 157 179 nil nil nil nil 174 170 196 nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
337 248 241 253 nil nil 230 nil 249 nil nil 246 175 172 171 nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
338 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
339 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil 205
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
340 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
341 144 145 146 147 148 149 150 151 152 153 154 nil nil nil nil nil]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
342 "Table for converting ISO-8859-8 characters into codepage 862 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 (setplist 'cp862-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
344 '(charset hebrew-iso8859-8 language "Hebrew" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
345
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
346 ;; French Canadian
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
347 (defvar cp863-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
348 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
349 255 nil 155 156 152 nil 160 143 164 nil nil 174 170 nil nil 167
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
350 nil 241 253 166 161 nil 134 249 165 nil nil 175 172 171 173 nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
351 142 nil 132 nil nil nil nil 128 145 144 146 148 nil nil 168 149
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
352 nil nil nil nil 153 nil nil nil nil 157 nil 158 154 nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
353 133 nil 131 nil nil nil nil 135 138 130 136 137 141 nil 140 139
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
354 nil nil nil 162 147 nil nil 246 nil 151 163 150 129 nil nil nil]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
355 "Table for converting ISO-8859-1 characters into codepage 863 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
356 (setplist 'cp863-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
357 '(charset latin-iso8859-1 language "Latin-1" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
358
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
359 ;; Arabic
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360 ;; FIXME: Emacs doesn't seem to support the "Arabic" language
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
361 ;; environment yet. So this is only partially usable, for now
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
362 (defvar cp864-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
363 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
364 255 nil nil nil 164 nil nil nil nil nil nil nil 172 161 nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
365 nil nil nil nil nil nil nil nil nil nil nil 187 nil nil nil 191
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
366 nil 193 194 195 196 nil 198 199 169 201 170 171 173 174 175 207
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
367 208 209 210 188 189 190 235 215 216 223 238 nil nil nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
368 224 247 248 252 251 239 242 243 232 233 253 nil nil nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
369 nil 241 nil nil nil nil nil nil nil nil nil nil nil nil nil nil]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
370 "Table for converting ISO-8859-1 characters into codepage 863 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
371 (setplist 'cp864-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
372 '(charset arabic-iso8859-6 language nil offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
373
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
374 ;; Nordic (Norwegian/Danish)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
375 (defvar cp865-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
376 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
377 255 173 nil 156 nil nil nil nil nil nil 166 174 170 nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
378 nil 241 253 nil nil nil nil 249 nil nil 167 175 172 171 nil 168
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
379 nil nil nil nil 142 143 146 128 nil 144 nil nil nil nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
380 nil 165 nil nil nil nil 153 nil 157 nil nil nil 154 nil nil nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381 133 160 131 nil 132 134 145 135 138 130 136 137 141 161 140 139
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
382 nil 164 149 162 147 nil 148 246 155 151 163 150 129 nil nil 152]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
383 "Table for converting ISO-8859-1 characters into codepage 865 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
384 (setplist 'cp865-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
385 '(charset latin-iso8859-1 language "Latin-1" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
386
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
387 ;; Greek (yes, another one!)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
388 (defvar cp869-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
389 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
390 255 139 140 156 nil nil 138 245 249 151 nil 174 137 240 nil 142
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
391 248 241 153 154 239 247 134 136 141 143 144 175 146 171 149 152
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
392 161 164 165 166 167 168 169 170 172 173 181 182 183 184 189 190
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
393 198 199 nil 207 208 209 210 211 212 213 145 150 155 157 158 159
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
394 252 214 215 216 221 222 224 225 226 227 228 229 230 231 232 233
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
395 234 235 237 236 238 242 243 244 246 250 160 251 162 163 253 nil]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
396 "Table for converting ISO-8859-7 characters into codepage 869 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
397 (setplist 'cp869-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
398 '(charset greek-iso8859-7 language "Greek" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
399
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
400 ;; Conversion from codepage 775 to Latin-4 for Baltic countries.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
401 (defvar cp775-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
402 [
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
403 255 181 nil 138 150 nil 234 245 166 190 237 149 173 240 207 nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
404 248 208 nil 139 239 nil 235 nil nil 213 137 133 nil nil 216 nil
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
405 160 nil nil nil 142 143 146 189 182 144 183 nil 184 nil nil 161
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
406 nil 238 226 232 nil 229 153 158 157 198 nil nil 154 nil 199 225
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407 131 nil nil nil 132 134 145 212 209 130 210 nil 211 nil nil 140
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
408 nil 236 147 233 nil 228 148 nil 155 214 nil nil 129 nil 215 nil]
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
409 "Table for converting ISO-8859-4 characters into codepage 775 glyphs.")
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
410 (setplist 'cp775-decode-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411 '(charset latin-iso8859-4 language "Latin-4" offset 160))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
412
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
413 ;;;###autoload
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414 (defun cp-make-coding-systems-for-codepage (codepage iso-name offset)
23952
4ef8ec98dd43 (cp-make-coding-systems-for-codepage): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 23920
diff changeset
415 "Create a coding system to convert IBM CODEPAGE into charset ISO-NAME
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
416 whose first character is at offset OFFSET from the beginning of 8-bit
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
417 ASCII table.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
418
23952
4ef8ec98dd43 (cp-make-coding-systems-for-codepage): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 23920
diff changeset
419 The created coding system has the usual 3 subsidiary systems: for Unix-,
4ef8ec98dd43 (cp-make-coding-systems-for-codepage): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 23920
diff changeset
420 DOS- and Mac-style EOL conversion. However, unlike built-in coding
4ef8ec98dd43 (cp-make-coding-systems-for-codepage): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 23920
diff changeset
421 systems, the Mac-style EOL conversion is currently not supported by the
4ef8ec98dd43 (cp-make-coding-systems-for-codepage): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 23920
diff changeset
422 decoder and encoder created by this function."
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
423 (let* ((decode-table (intern (format "%s-decode-table" codepage)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
424 (nonascii-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
425 (intern (format "%s-nonascii-translation-table" codepage)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
426 (decode-translation
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
427 (intern (format "%s-decode-translation-table" codepage)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
428 (encode-translation
23920
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
429 (intern (format "%s-encode-translation-table" codepage))))
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
430 (set nonascii-table
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
431 (make-translation-table-from-vector
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
432 (cp-decoding-vector-for-codepage
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
433 (symbol-value decode-table) iso-name offset)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
434 (define-translation-table encode-translation
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
435 (char-table-extra-slot (symbol-value nonascii-table) 0))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
436 ;; For charsets other than ascii and ISO-NAME, set `?' for
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
437 ;; one-column charsets, and some Japanese character for
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
438 ;; wide-column charsets. CCL encoder convert that Japanese
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
439 ;; character to "??".
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
440 (let ((tbl (char-table-extra-slot (symbol-value nonascii-table) 0))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
441 (charsets (delq 'ascii (delq iso-name
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
442 (copy-sequence charset-list))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
443 (wide-column-char (make-char 'japanese-jisx0208 32 32)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
444 (while charsets
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
445 (aset tbl (make-char (car charsets))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
446 (if (= (charset-width (car charsets)) 1) ?? wide-column-char))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
447 (setq charsets (cdr charsets))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
448 (define-translation-table decode-translation
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
449 (symbol-value nonascii-table))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
450 (cp-coding-system-for-codepage-1
23920
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
451 (intern codepage) ?D iso-name decode-translation encode-translation)
efcf2fcda617 (cp-coding-system-for-codepage-1):
Eli Zaretskii <eliz@gnu.org>
parents: 23915
diff changeset
452 ))
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
453
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
454 (defun cp-codepage-decoder (codepage)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
455 "If CODEPAGE is the name of a supported codepage, return its decode table;
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
456 otherwise return nil."
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
457 (let ((cp (if (symbolp codepage) (symbol-name codepage) codepage)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
458 (cond
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
459 ((stringp cp)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
460 (intern-soft (format "%s-decode-table" cp)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
461 (t nil))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
462
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
463 ;;;###autoload
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
464 (defun cp-charset-for-codepage (codepage)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
465 "Return the charset for which there is a translation table to DOS CODEPAGE.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
466 CODEPAGE must be the name of a DOS codepage, a string."
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
467 (let ((cp-decoder (cp-codepage-decoder codepage)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
468 (if (null cp-decoder)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
469 (error "Unsupported codepage %s" codepage)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
470 (get cp-decoder 'charset))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
471
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
472 ;;;###autoload
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
473 (defun cp-language-for-codepage (codepage)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
474 "Return the name of the MULE language environment for CODEPAGE.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
475 CODEPAGE must be the name of a DOS codepage, a string."
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
476 (let ((cp-decoder (cp-codepage-decoder codepage)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
477 (if (null cp-decoder)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
478 (error "Unsupported codepage %s" codepage)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
479 (get cp-decoder 'language))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
480
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
481 ;;;###autoload
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
482 (defun cp-offset-for-codepage (codepage)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
483 "Return the offset to be used in setting up coding systems for CODEPAGE.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
484 CODEPAGE must be the name of a DOS codepage, a string."
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
485 (let ((cp-decoder (cp-codepage-decoder codepage)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
486 (if (null cp-decoder)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
487 (error "Unsupported codepage %s" codepage)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
488 (get cp-decoder 'offset))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
489
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
490 ;;;###autoload
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
491 (defun cp-supported-codepages ()
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
492 "Return an alist of supported codepages.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
493
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
494 Each association in the alist has the form (NNN . CHARSET), where NNN is the
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
495 codepage number, and CHARSET is the MULE charset which is the closest match
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
496 for the character set supported by that codepage.
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
497
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
498 A codepage NNN is supported if a variable called `cpNNN-decode-table' exists,
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
499 is a vector, and has a charset property."
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
500 (save-match-data
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
501 (let (alist chset sname)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
502 (mapatoms
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
503 (function
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
504 (lambda (sym)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
505 (if (and (boundp sym)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
506 (string-match "\\`cp\\([1-9][0-9][0-9]\\)-decode-table\\'"
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
507 (setq sname (symbol-name sym)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
508 (vectorp (symbol-value sym))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
509 (setq chset (get sym 'charset)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
510 (setq alist
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
511 (cons (cons (match-string 1 sname) chset) alist))))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
512 alist)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
513
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
514 ;;;###autoload
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
515 (defun codepage-setup (codepage)
24033
a5d31e58291b (codepage-setup): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 24009
diff changeset
516 "Create a coding system cpCODEPAGE to support the IBM codepage CODEPAGE.
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
517
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
518 These coding systems are meant for encoding and decoding 8-bit non-ASCII
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
519 characters used by the IBM codepages, typically in conjunction with files
24033
a5d31e58291b (codepage-setup): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 24009
diff changeset
520 read/written by MS-DOS software, or for display on the MS-DOS terminal."
23915
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
521 (interactive
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
522 (let ((completion-ignore-case t)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
523 (candidates (cp-supported-codepages)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
524 (list (completing-read "Setup DOS Codepage: (default 437) " candidates
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
525 nil t nil nil "437"))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
526 (let ((cp (format "cp%s" codepage)))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
527 (cp-make-coding-systems-for-codepage
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
528 cp (cp-charset-for-codepage cp) (cp-offset-for-codepage cp))))
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
529
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
530 (provide 'codepage)
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
531
7ce49fb0dfbc Initial revision
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
532 ;; codepage.el ends here