]> code.delx.au - gnu-emacs/blobdiff - lisp/international/codepage.el
(make-subsidiary-coding-system): Reset
[gnu-emacs] / lisp / international / codepage.el
index 871148f6fbe3b21d27d2cded9d6520c4401e778b..56920b968ac623784c54fa370eba9e50425aeb0e 100644 (file)
@@ -1,6 +1,9 @@
-;;; codepage.el --- MS-DOS/MS-Windows specific coding systems.
+;;; codepage.el --- MS-DOS/MS-Windows specific coding systems
 
-;; Copyright (C) 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2002  Free Software Foundation, Inc.
+;; Copyright (C) 2000
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Author: Eli Zaretskii
 ;; Maintainer: FSF
@@ -20,8 +23,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 ;; terminal display and input methods.
 ;;
 ;; Thanks to Ken'ichi Handa <handa@etl.go.jp> for writing the CCL
-;; encoders/decoders, and for help in debugging this code. 
+;; encoders/decoders, and for help in debugging this code.
 
 ;;; Code:
 
+(defvar dos-unsupported-char-glyph)
+
 (defun cp-coding-system-for-codepage-1 (coding mnemonic iso-name
                                               decoder encoder)
   "Make coding system CODING for a DOS codepage using translation tables.
@@ -384,7 +389,7 @@ character is generated by (make-char CHARSET OFFSET)."
    128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
    160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
-   223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
+   224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
    252 241 nil nil 243 nil nil 245 nil nil nil nil nil nil 247 nil]
   "Table for converting ISO-8859-5 characters into codepage 866 glyphs.")
 (setplist 'cp866-decode-table
@@ -492,7 +497,7 @@ character is generated by (make-char CHARSET OFFSET)."
     208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
     224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
     240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 ]
-  "ISO-8859-2 to Windows-1250 (Central Europe) codepage decoding table")
+  "ISO-8859-2 to Windows-1250 (Central Europe) codepage decoding table.")
 (setplist 'cp1250-decode-table
           '(charset latin-iso8859-2 language "Latin-2" offset 160))
 
@@ -504,7 +509,7 @@ character is generated by (make-char CHARSET OFFSET)."
     224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
     240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
     185 184 144 131 186 190 179 191 188 154 156 158 157 167 162 159 ]
-  "ISO-8859-5 to Windows-1251 (Cyrillic) codepage decoding table")
+  "ISO-8859-5 to Windows-1251 (Cyrillic) codepage decoding table.")
 (setplist 'cp1251-decode-table
           '(charset cyrillic-iso8859-5 language "Cyrillic-ISO" offset 160))
 
@@ -519,7 +524,7 @@ character is generated by (make-char CHARSET OFFSET)."
     208 209 nil 211 212 213 214 215 216 217 218 219 220 221 222 223
     224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
     240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 nil ]
-  "ISO-8859-7 to Windows-1253 (Greek) codepage decoding table")
+  "ISO-8859-7 to Windows-1253 (Greek) codepage decoding table.")
 (setplist 'cp1253-decode-table
           '(charset greek-iso8859-7 language "Greek" offset 160))
 
@@ -534,7 +539,7 @@ character is generated by (make-char CHARSET OFFSET)."
     nil 210 212 205 nil 213 214 215 168 216 nil nil 220 nil 219 223
     226 nil nil nil 228 229 191 225 232 233 230 nil 235 nil nil 238
     nil 242 244 237 nil 245 246 247 184 248 nil nil 252 nil 251 nil ]
-  "ISO-8859-4 to Windows-1257 (Baltic) codepage decoding table")
+  "ISO-8859-4 to Windows-1257 (Baltic) codepage decoding table.")
 (setplist 'cp1257-decode-table
           '(charset latin-iso8859-4 language "Latin-4" offset 160))
 
@@ -588,8 +593,8 @@ decoder and encoder created by this function."
     ))
 
 (defun cp-codepage-decoder (codepage)
-  "If CODEPAGE is the name of a supported codepage, return its decode table;
-otherwise return nil."
+  "If CODEPAGE is the name of a supported codepage, return its decode table.
+Otherwise return nil."
   (let ((cp (if (symbolp codepage) (symbol-name codepage) codepage)))
     (cond
      ((stringp cp)
@@ -657,12 +662,35 @@ read/written by MS-DOS software, or for display on the MS-DOS terminal."
   (interactive
    (let ((completion-ignore-case t)
         (candidates (cp-supported-codepages)))
-     (list (completing-read "Setup DOS Codepage: (default 437) " candidates
+     (list (completing-read "Setup DOS Codepage (default 437): " candidates
                            nil t nil nil "437"))))
-  (let ((cp (format "cp%s" codepage)))
-    (cp-make-coding-systems-for-codepage
-     cp (cp-charset-for-codepage cp) (cp-offset-for-codepage cp))))
+  (let* ((cp (format "cp%s" codepage))
+        (cp-defined (intern-soft cp)))
+    (or (and cp-defined  ;; avoid defining if already defined
+            (coding-system-p cp-defined))
+       (cp-make-coding-systems-for-codepage
+        cp (cp-charset-for-codepage cp) (cp-offset-for-codepage cp)))))
+
+;; Add DOS codepages to `non-iso-charset-alist'.
+(eval-after-load "mule-diag"
+  '(let ((tail (cp-supported-codepages))
+        elt)
+     (while tail
+       (setq elt (car tail) tail (cdr tail))
+       ;; Now ELT is (CODEPAGE . CHARSET), where CODEPAGE is a string
+       ;; (e.g. "850"), CHARSET is a charset that characters in CODEPAGE
+       ;; are mapped to.
+       (unless (assq (intern (concat "cp" (car elt))) non-iso-charset-alist)
+        (setq non-iso-charset-alist
+              (cons (list (intern (concat "cp" (car elt)))
+                          (list 'ascii (cdr elt))
+                          `(lambda (code)
+                             (decode-codepage-char ,(string-to-int (car elt))
+                                                   code))
+                          (list (list 0 255)))
+                    non-iso-charset-alist))))))
 
 (provide 'codepage)
 
-;; codepage.el ends here
+;;; arch-tag: 80328de8-b94e-4386-be26-5876105731f0
+;;; codepage.el ends here