mule.el 92.1 KB
Newer Older
Dave Love's avatar
Dave Love committed
1
;;; mule.el --- basic commands for multilingual environment
Karl Heuer's avatar
Karl Heuer committed
2

3
;; Copyright (C) 1997-2012 Free Software Foundation, Inc.
Kenichi Handa's avatar
Kenichi Handa committed
4
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5
;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
Kenichi Handa's avatar
Kenichi Handa committed
6 7
;;   National Institute of Advanced Industrial Science and Technology (AIST)
;;   Registration Number H14PRO021
Kenichi Handa's avatar
Kenichi Handa committed
8
;; Copyright (C) 2003
9 10
;;   National Institute of Advanced Industrial Science and Technology (AIST)
;;   Registration Number H13PRO009
Karl Heuer's avatar
Karl Heuer committed
11 12 13 14 15

;; Keywords: mule, multilingual, character set, coding system

;; This file is part of GNU Emacs.

16
;; GNU Emacs is free software: you can redistribute it and/or modify
Karl Heuer's avatar
Karl Heuer committed
17
;; it under the terms of the GNU General Public License as published by
18 19
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
Karl Heuer's avatar
Karl Heuer committed
20 21 22 23 24 25 26

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
27
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
Karl Heuer's avatar
Karl Heuer committed
28

29 30
;;; Commentary:

Karl Heuer's avatar
Karl Heuer committed
31 32
;;; Code:

33
;; FIXME?  Are these still relevant?  Nothing uses them AFAICS.
Kenichi Handa's avatar
Kenichi Handa committed
34
(defconst mule-version "6.0 (HANACHIRUSATO)" "\
Karl Heuer's avatar
Karl Heuer committed
35 36
Version number and name of this version of MULE (multilingual environment).")

Kenichi Handa's avatar
Kenichi Handa committed
37
(defconst mule-version-date "2003.9.1" "\
Karl Heuer's avatar
Karl Heuer committed
38 39
Distribution date of this version of MULE (multilingual environment).")

40 41 42

;;; CHARSET

Kenichi Handa's avatar
Kenichi Handa committed
43 44 45 46 47 48 49 50 51 52
;; Backward compatibility code for handling emacs-mule charsets.
(defvar private-char-area-1-min #xF0000)
(defvar private-char-area-1-max #xFFFFE)
(defvar private-char-area-2-min #x100000)
(defvar private-char-area-2-max #x10FFFE)

;; Table of emacs-mule charsets indexed by their emacs-mule ID.
(defvar emacs-mule-charset-table (make-vector 256 nil))
(aset emacs-mule-charset-table 0 'ascii)

53
;; Convert the argument of old-style call of define-charset to a
Kenichi Handa's avatar
Kenichi Handa committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
;; property list used by the new-style.
;; INFO-VECTOR is a vector of the format:
;;   [DIMENSION CHARS WIDTH DIRECTION ISO-FINAL-CHAR ISO-GRAPHIC-PLANE
;;    SHORT-NAME LONG-NAME DESCRIPTION]

(defun convert-define-charset-argument (emacs-mule-id info-vector)
  (let* ((dim (aref info-vector 0))
	 (chars (aref info-vector 1))
	 (total (if (= dim 1) chars (* chars chars)))
	 (code-space (if (= dim 1) (if (= chars 96) [32 127] [33 126])
		       (if (= chars 96) [32 127 32 127] [33 126 33 126])))
	 code-offset)
    (if (integerp emacs-mule-id)
	(or (= emacs-mule-id 0)
	    (and (>= emacs-mule-id 129) (< emacs-mule-id 256))
	    (error "Invalid CHARSET-ID: %d" emacs-mule-id))
      (let (from-id to-id)
	(if (= dim 1) (setq from-id 160 to-id 224)
	  (setq from-id 224 to-id 255))
	(while (and (< from-id to-id)
		    (not (aref emacs-mule-charset-table from-id)))
	  (setq from-id (1+ from-id)))
	(if (= from-id to-id)
	    (error "No more room for the new Emacs-mule charset"))
	(setq emacs-mule-id from-id)))
    (if (> (- private-char-area-1-max private-char-area-1-min) total)
	(setq code-offset private-char-area-1-min
	      private-char-area-1-min (+ private-char-area-1-min total))
      (if (> (- private-char-area-2-max private-char-area-2-min) total)
	  (setq code-offset private-char-area-2-min
		private-char-area-2-min (+ private-char-area-2-min total))
85
	(error "No more space for a new charset")))
Kenichi Handa's avatar
Kenichi Handa committed
86 87 88 89 90 91
    (list :dimension dim
	  :code-space code-space
	  :iso-final-char (aref info-vector 4)
	  :code-offset code-offset
	  :emacs-mule-id emacs-mule-id)))

92 93 94
(defun define-charset (name docstring &rest props)
  "Define NAME (symbol) as a charset with DOCSTRING.
The remaining arguments must come in pairs ATTRIBUTE VALUE.  ATTRIBUTE
Dave Love's avatar
Dave Love committed
95
may be any symbol.  The following have special meanings, and one of
Kenichi Handa's avatar
Kenichi Handa committed
96
`:code-offset', `:map', `:subset', `:superset' must be specified.
97 98 99 100 101 102 103 104 105

`:short-name'

VALUE must be a short string to identify the charset.  If omitted,
NAME is used.

`:long-name'

VALUE must be a string longer than `:short-name' to identify the
Dave Love's avatar
Dave Love committed
106
charset.  If omitted, the value of the `:short-name' attribute is used.
107 108 109 110

`:dimension'

VALUE must be an integer 0, 1, 2, or 3, specifying the dimension of
Dave Love's avatar
Dave Love committed
111 112
code-points of the charsets.  If omitted, it is calculated from the
value of the `:code-space' attribute.
113 114 115 116 117 118

`:code-space'

VALUE must be a vector of length at most 8 specifying the byte code
range of each dimension in this format:
	[ MIN-1 MAX-1 MIN-2 MAX-2 ... ]
Dave Love's avatar
Dave Love committed
119
where MIN-N is the minimum byte value of Nth dimension of code-point,
120 121
MAX-N is the maximum byte value of that.

122 123
`:min-code'

Juanma Barranquero's avatar
Juanma Barranquero committed
124
VALUE must be an integer specifying the minimum code point of the
125 126 127 128
charset.  If omitted, it is calculated from `:code-space'.  VALUE may
be a cons (HIGH . LOW), where HIGH is the most significant 16 bits of
the code point and LOW is the least significant 16 bits.

129
`:max-code'
130

Juanma Barranquero's avatar
Juanma Barranquero committed
131
VALUE must be an integer specifying the maximum code point of the
132 133 134 135
charset.  If omitted, it is calculated from `:code-space'.  VALUE may
be a cons (HIGH . LOW), where HIGH is the most significant 16 bits of
the code point and LOW is the least significant 16 bits.

136 137 138 139 140 141 142 143 144 145 146 147 148 149
`:iso-final-char'

VALUE must be a character in the range 32 to 127 (inclusive)
specifying the final char of the charset for ISO-2022 encoding.  If
omitted, the charset can't be encoded by ISO-2022 based
coding-systems.

`:iso-revision-number'

VALUE must be an integer in the range 0..63, specifying the revision
number of the charset for ISO-2022 encoding.

`:emacs-mule-id'

Kenichi Handa's avatar
Kenichi Handa committed
150
VALUE must be an integer of 0, 129..255.  If omitted, the charset
151 152 153 154
can't be encoded by coding-systems of type `emacs-mule'.

`:ascii-compatible-p'

Dave Love's avatar
Dave Love committed
155 156
VALUE must be nil or t (default nil).  If VALUE is t, the charset is
compatible with ASCII, i.e. the first 128 code points map to ASCII.
157 158 159 160

`:supplementary-p'

VALUE must be nil or t.  If the VALUE is t, the charset is
161 162 163
supplementary, which means it is used only as a parent or a
subset of some other charset, or it is provided just for backward
compatibility.
164 165 166 167 168

`:invalid-code'

VALUE must be a nonnegative integer that can be used as an invalid
code point of the charset.  If the minimum code is 0 and the maximum
169
code is greater than Emacs's maximum integer value, `:invalid-code'
170 171 172 173
should not be omitted.

`:code-offset'

Dave Love's avatar
Dave Love committed
174 175
VALUE must be an integer added to the index number of a character to
get the corresponding character code.
176 177 178 179 180 181 182

`:map'

VALUE must be vector or string.

If it is a vector, the format is [ CODE-1 CHAR-1 CODE-2 CHAR-2 ... ],
where CODE-n is a code-point of the charset, and CHAR-n is the
Dave Love's avatar
Dave Love committed
183
corresponding character code.
184 185

If it is a string, it is a name of file that contains the above
Kenichi Handa's avatar
Kenichi Handa committed
186 187 188 189 190
information.   Each line of the file must be this format:
	0xXXX 0xYYY
where XXX is a hexadecimal representation of CODE-n and YYY is a
hexadecimal representation of CHAR-n.  A line starting with `#' is a
comment line.
191

192 193 194 195 196 197 198 199 200 201
`:subset'

VALUE must be a list:
	( PARENT MIN-CODE MAX-CODE OFFSET )
PARENT is a parent charset.  MIN-CODE and MAX-CODE specify the range
of characters inherited from the parent.  OFFSET is an integer value
to add to a code point of the parent charset to get the corresponding
code point of this charset.

`:superset'
202 203 204 205

VALUE must be a list of parent charsets.  The charset inherits
characters from them.  Each element of the list may be a cons (PARENT
. OFFSET), where PARENT is a parent charset, and OFFSET is an offset
206 207
value to add to a code point of PARENT to get the corresponding code
point of this charset.
208 209 210 211 212 213 214

`:unify-map'

VALUE must be vector or string.

If it is a vector, the format is [ CODE-1 CHAR-1 CODE-2 CHAR-2 ... ],
where CODE-n is a code-point of the charset, and CHAR-n is the
Dave Love's avatar
Dave Love committed
215
corresponding Unicode character code.
216 217

If it is a string, it is a name of file that contains the above
Kenichi Handa's avatar
Kenichi Handa committed
218 219
information.  The file format is the same as what described for `:map'
attribute."
Kenichi Handa's avatar
Kenichi Handa committed
220 221 222 223 224 225 226 227
  (when (vectorp (car props))
    ;; Old style code:
    ;;   (define-charset CHARSET-ID CHARSET-SYMBOL INFO-VECTOR)
    ;; Convert the argument to make it fit with the current style.
    (let ((vec (car props)))
      (setq props (convert-define-charset-argument name vec)
	    name docstring
	    docstring (aref vec 8))))
228 229
  (let ((attrs (mapcar 'list '(:dimension
			       :code-space
230 231
			       :min-code
			       :max-code
232 233 234 235 236 237 238 239
			       :iso-final-char
			       :iso-revision-number
			       :emacs-mule-id
			       :ascii-compatible-p
			       :supplementary-p
			       :invalid-code
			       :code-offset
			       :map
240 241
			       :subset
			       :superset
242 243 244 245 246 247
			       :unify-map
			       :plist))))

    ;; If :dimension is omitted, get the dimension from :code-space.
    (let ((dimension (plist-get props :dimension)))
      (or dimension
248 249
	  (let ((code-space (plist-get props :code-space)))
	    (setq dimension (if code-space (/ (length code-space) 2) 4))
250 251
	    (setq props (plist-put props :dimension dimension)))))

252 253 254 255 256 257 258 259
    (let ((code-space (plist-get props :code-space)))
      (or code-space
	  (let ((dimension (plist-get props :dimension)))
	    (setq code-space (make-vector 8 0))
	    (dotimes (i dimension)
	      (aset code-space (1+ (* i 2)) #xFF))
	    (setq props (plist-put props :code-space code-space)))))

Kenichi Handa's avatar
Kenichi Handa committed
260 261 262 263 264
    ;; If :emacs-mule-id is specified, update emacs-mule-charset-table.
    (let ((emacs-mule-id (plist-get props :emacs-mule-id)))
      (if (integerp emacs-mule-id)
	  (aset emacs-mule-charset-table emacs-mule-id name)))

265
    (dolist (slot attrs)
266
      (setcdr slot (purecopy (plist-get props (car slot)))))
267 268 269 270 271 272 273 274 275 276 277 278

    ;; Make sure that the value of :code-space is a vector of 8
    ;; elements.
    (let* ((slot (assq :code-space attrs))
	   (val (cdr slot))
	   (len (length val)))
      (if (< len 8)
	  (setcdr slot
		  (vconcat val (make-vector (- 8 len) 0)))))

    ;; Add :name and :docstring properties to PROPS.
    (setq props
279
	  (cons :name (cons name (cons :docstring (cons (purecopy docstring) props)))))
280 281 282 283
    (or (plist-get props :short-name)
	(plist-put props :short-name (symbol-name name)))
    (or (plist-get props :long-name)
	(plist-put props :long-name (plist-get props :short-name)))
284
    (plist-put props :base name)
Dave Love's avatar
Dave Love committed
285 286 287 288 289 290 291
    ;; We can probably get a worthwhile amount in purespace.
    (setq props
	  (mapcar (lambda (elt)
		    (if (stringp elt)
			(purecopy elt)
		      elt))
		  props))
292 293 294 295 296
    (setcdr (assq :plist attrs) props)

    (apply 'define-charset-internal name (mapcar 'cdr attrs))))


Karl Heuer's avatar
Karl Heuer committed
297
(defun load-with-code-conversion (fullname file &optional noerror nomessage)
298 299
  "Execute a file of Lisp code named FILE whose absolute name is FULLNAME.
The file contents are decoded before evaluation if necessary.
300
If optional third arg NOERROR is non-nil,
Karl Heuer's avatar
Karl Heuer committed
301 302
 report no error if FILE doesn't exist.
Print messages at start and end of loading unless
303
 optional fourth arg NOMESSAGE is non-nil.
Karl Heuer's avatar
Karl Heuer committed
304 305 306 307 308 309
Return t if file exists."
  (if (null (file-readable-p fullname))
      (and (null noerror)
	   (signal 'file-error (list "Cannot open load file" file)))
    ;; Read file with code conversion, and then eval.
    (let* ((buffer
310 311 312
            ;; We can't use `generate-new-buffer' because files.el
            ;; is not yet loaded.
            (get-buffer-create (generate-new-buffer-name " *load*")))
313 314 315 316 317 318 319
	   (load-in-progress t)
	   (source (save-match-data (string-match "\\.el\\'" fullname))))
      (unless nomessage
	(if source
	    (message "Loading %s (source)..." file)
	  (message "Loading %s..." file)))
      (when purify-flag
320
	(push (purecopy file) preloaded-file-list))
Karl Heuer's avatar
Karl Heuer committed
321
      (unwind-protect
322
	  (let ((load-file-name fullname)
323
		(set-auto-coding-for-load t)
324
		(inhibit-file-name-operation nil))
325
	    (with-current-buffer buffer
326 327
              ;; So that we don't get completely screwed if the
              ;; file is encoded in some complicated character set,
328
              ;; read it with real decoding, as a multibyte buffer.
329
              (set-buffer-multibyte t)
330 331 332
	      ;; Don't let deactivate-mark remain set.
	      (let (deactivate-mark)
		(insert-file-contents fullname))
333 334 335 336 337
	      ;; If the loaded file was inserted with no-conversion or
	      ;; raw-text coding system, make the buffer unibyte.
	      ;; Otherwise, eval-buffer might try to interpret random
	      ;; binary junk as multibyte characters.
	      (if (and enable-multibyte-characters
Kenichi Handa's avatar
Kenichi Handa committed
338 339
		       (or (eq (coding-system-type last-coding-system-used)
			       'raw-text)))
340
		  (set-buffer-multibyte nil))
Karl Heuer's avatar
Karl Heuer committed
341 342
	      ;; Make `kill-buffer' quiet.
	      (set-buffer-modified-p nil))
343
	    ;; Have the original buffer current while we eval.
344 345 346
	    (eval-buffer buffer nil
			 ;; This is compatible with what `load' does.
			 (if purify-flag file fullname)
347
			 nil t))
348 349
	(let (kill-buffer-hook kill-buffer-query-functions)
	  (kill-buffer buffer)))
350
      (do-after-load-evaluation fullname)
351

352 353 354 355
      (unless (or nomessage noninteractive)
	(if source
	    (message "Loading %s (source)...done" file)
	  (message "Loading %s...done" file)))
Karl Heuer's avatar
Karl Heuer committed
356 357
      t)))

Kenichi Handa's avatar
Kenichi Handa committed
358
(defun charset-info (charset)
Karl Heuer's avatar
Karl Heuer committed
359
  "Return a vector of information of CHARSET.
Kenichi Handa's avatar
Kenichi Handa committed
360
This function is provided for backward compatibility.
Karl Heuer's avatar
Karl Heuer committed
361 362 363 364 365 366

The elements of the vector are:
	CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
	LEADING-CODE-BASE, LEADING-CODE-EXT,
	ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
	REVERSE-CHARSET, SHORT-NAME, LONG-NAME,	DESCRIPTION,
Kenichi Handa's avatar
Kenichi Handa committed
367
	PLIST.
Karl Heuer's avatar
Karl Heuer committed
368
where
Kenichi Handa's avatar
Kenichi Handa committed
369 370 371 372 373 374 375 376 377 378
CHARSET-ID is always 0.
BYTES is always 0.
DIMENSION is the number of bytes of a code-point of the charset:
  1, 2, 3, or 4.
CHARS is the number of characters in a dimension:
  94, 96, 128, or 256.
WIDTH is always 0.
DIRECTION is always 0.
LEADING-CODE-BASE is always 0.
LEADING-CODE-EXT is always 0.
Karl Heuer's avatar
Karl Heuer committed
379
ISO-FINAL-CHAR (character) is the final character of the
Kenichi Handa's avatar
Kenichi Handa committed
380 381
  corresponding ISO 2022 charset.  If the charset is not assigned
  any final character, the value is -1.
Kenichi Handa's avatar
Kenichi Handa committed
382 383
ISO-GRAPHIC-PLANE is always 0.
REVERSE-CHARSET is always -1.
Karl Heuer's avatar
Karl Heuer committed
384 385 386 387 388 389
SHORT-NAME (string) is the short name to refer to the charset.
LONG-NAME (string) is the long name to refer to the charset
DESCRIPTION (string) is the description string of the charset.
PLIST (property list) may contain any type of information a user
  want to put and get by functions `put-charset-property' and
  `get-charset-property' respectively."
Kenichi Handa's avatar
Kenichi Handa committed
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
  (vector 0
	  0
	  (charset-dimension charset)
	  (charset-chars charset)
	  0
	  0
	  0
	  0
	  (charset-iso-final-char charset)
	  0
	  -1
	  (get-charset-property charset :short-name)
	  (get-charset-property charset :short-name)
	  (charset-description charset)
	  (charset-plist charset)))
Karl Heuer's avatar
Karl Heuer committed
405

406 407 408 409
;; It is better not to use backquote in this file,
;; because that makes a bootstrapping problem
;; if you need to recompile all the Lisp files using interpreted code.

Kenichi Handa's avatar
Kenichi Handa committed
410 411
(defun charset-id (charset)
  "Always return 0.  This is provided for backward compatibility."
412
  (declare (obsolete nil "23.1"))
Kenichi Handa's avatar
Kenichi Handa committed
413
  0)
Karl Heuer's avatar
Karl Heuer committed
414 415

(defmacro charset-bytes (charset)
Kenichi Handa's avatar
Kenichi Handa committed
416
  "Always return 0.  This is provided for backward compatibility."
417
  (declare (obsolete nil "23.1"))
Kenichi Handa's avatar
Kenichi Handa committed
418
  0)
419 420 421 422 423 424 425 426

(defun get-charset-property (charset propname)
  "Return the value of CHARSET's PROPNAME property.
This is the last value stored with
 (put-charset-property CHARSET PROPNAME VALUE)."
  (plist-get (charset-plist charset) propname))

(defun put-charset-property (charset propname value)
427
  "Set CHARSETS's PROPNAME property to value VALUE.
428 429
It can be retrieved with `(get-charset-property CHARSET PROPNAME)'."
  (set-charset-plist charset
430 431 432 433
		     (plist-put (charset-plist charset) propname
				(if (stringp value)
				    (purecopy value)
				  value))))
434 435 436 437 438 439

(defun charset-description (charset)
  "Return description string of CHARSET."
  (plist-get (charset-plist charset) :docstring))

(defun charset-dimension (charset)
Dave Love's avatar
Dave Love committed
440
  "Return dimension of CHARSET."
441 442
  (plist-get (charset-plist charset) :dimension))

443
(defun charset-chars (charset &optional dimension)
Dave Love's avatar
Dave Love committed
444
  "Return number of characters contained in DIMENSION of CHARSET.
445 446
DIMENSION defaults to the first dimension."
  (unless dimension (setq dimension 1))
Kenichi Handa's avatar
Kenichi Handa committed
447
  (let ((code-space (plist-get (charset-plist charset) :code-space)))
448 449
    (1+ (- (aref code-space (1- (* 2 dimension)))
	   (aref code-space (- (* 2 dimension) 2))))))
450 451

(defun charset-iso-final-char (charset)
Dave Love's avatar
Dave Love committed
452 453
  "Return ISO-2022 final character of CHARSET.
Return -1 if charset isn't an ISO 2022 one."
454 455
  (or (plist-get (charset-plist charset) :iso-final-char)
      -1))
Karl Heuer's avatar
Karl Heuer committed
456 457

(defmacro charset-short-name (charset)
458 459
  "Return short name of CHARSET."
  (plist-get (charset-plist charset) :short-name))
Karl Heuer's avatar
Karl Heuer committed
460 461

(defmacro charset-long-name (charset)
462 463
  "Return long name of CHARSET."
  (plist-get (charset-plist charset) :long-name))
Karl Heuer's avatar
Karl Heuer committed
464

465
(defun charset-list ()
466
  "Return list of all charsets ever defined."
467
  (declare (obsolete charset-list "23.1"))
468 469
  charset-list)

Kenichi Handa's avatar
Kenichi Handa committed
470 471

;;; CHARACTER
472
(define-obsolete-function-alias 'char-valid-p 'characterp "23.1")
Kenichi Handa's avatar
Kenichi Handa committed
473

474
(defun generic-char-p (char)
Kenichi Handa's avatar
Kenichi Handa committed
475
  "Always return nil.  This is provided for backward compatibility."
476
  (declare (obsolete nil "23.1"))
477
  nil)
Kenichi Handa's avatar
Kenichi Handa committed
478 479 480 481 482 483

(defun make-char-internal (charset-id &optional code1 code2)
  (let ((charset (aref emacs-mule-charset-table charset-id)))
    (or charset
	(error "Invalid Emacs-mule charset ID: %d" charset-id))
    (make-char charset code1 code2)))
484

Chong Yidong's avatar
Chong Yidong committed
485 486 487 488 489 490 491 492 493 494 495 496 497 498
;; Save the ASCII case table in case we need it later.  Some locales
;; (such as Turkish) modify the case behavior of ASCII characters,
;; which can interfere with networking code that uses ASCII strings.

(defvar ascii-case-table
  ;; Code copied from copy-case-table to avoid requiring case-table.el
  (let ((tbl (copy-sequence (standard-case-table)))
	(up  (char-table-extra-slot (standard-case-table) 0)))
    (if up (set-char-table-extra-slot tbl 0 (copy-sequence up)))
    (set-char-table-extra-slot tbl 1 nil)
    (set-char-table-extra-slot tbl 2 nil)
    tbl)
  "Case table for the ASCII character set.")

499
;; Coding system stuff
Karl Heuer's avatar
Karl Heuer committed
500

501 502
;; Coding system is a symbol that has been defined by the function
;; `define-coding-system'.
Karl Heuer's avatar
Karl Heuer committed
503

504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
(defconst coding-system-iso-2022-flags
  '(long-form
    ascii-at-eol
    ascii-at-cntl
    7-bit
    locking-shift
    single-shift
    designation
    revision
    direction
    init-at-bol
    designate-at-bol
    safe
    latin-extra
    composition
519 520 521
    euc-tw-shift
    use-roman
    use-oldjis)
522
  "List of symbols that control ISO-2022 encoder/decoder.
Karl Heuer's avatar
Karl Heuer committed
523

Dave Love's avatar
Dave Love committed
524
The value of the `:flags' attribute in the argument of the function
525
`define-coding-system' must be one of them.
Karl Heuer's avatar
Karl Heuer committed
526

527 528 529
If `long-form' is specified, use a long designation sequence on
encoding for the charsets `japanese-jisx0208-1978', `chinese-gb2312',
and `japanese-jisx0208'.  The long designation sequence doesn't
Dave Love's avatar
Dave Love committed
530
conform to ISO 2022, but is used by such coding systems as
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
`compound-text'.

If `ascii-at-eol' is specified, designate ASCII to g0 at end of line
on encoding.

If `ascii-at-cntl' is specified, designate ASCII to g0 before control
codes and SPC on encoding.

If `7-bit' is specified, use 7-bit code only on encoding.

If `locking-shift' is specified, decode locking-shift code correctly
on decoding, and use locking-shift to invoke a graphic element on
encoding.

If `single-shift' is specified, decode single-shift code correctly on
decoding, and use single-shift to invoke a graphic element on encoding.

If `designation' is specified, decode designation code correctly on
decoding, and use designation to designate a charset to a graphic
element on encoding.

If `revision' is specified, produce an escape sequence to specify
revision number of a charset on encoding.  Such an escape sequence is
always correctly decoded on decoding.

If `direction' is specified, decode ISO6429's code for specifying
Dave Love's avatar
Dave Love committed
557
direction correctly, and produce the code on encoding.
558 559 560

If `init-at-bol' is specified, on encoding, it is assumed that
invocation and designation statuses are reset at each beginning of
Dave Love's avatar
Dave Love committed
561
line even if `ascii-at-eol' is not specified; thus no codes for
562 563 564 565 566
resetting them are produced.

If `safe' is specified, on encoding, characters not supported by a
coding are replaced with `?'.

Dave Love's avatar
Dave Love committed
567
If `latin-extra' is specified, the code-detection routine assumes that a
568 569 570
code specified in `latin-extra-code-table' (which see) is valid.

If `composition' is specified, an escape sequence to specify
Dave Love's avatar
Dave Love committed
571
composition sequence is correctly decoded on decoding, and is produced
572 573 574
on encoding.

If `euc-tw-shift' is specified, the EUC-TW specific shifting code is
Dave Love's avatar
Dave Love committed
575
correctly decoded on decoding, and is produced on encoding.
576

Dave Love's avatar
Dave Love committed
577 578 579 580 581 582
If `use-roman' is specified, JIS0201-1976-Roman is designated instead
of ASCII.

If `use-oldjis' is specified, JIS0208-1976 is designated instead of
JIS0208-1983.")

583
(defun define-coding-system (name docstring &rest props)
Dave Love's avatar
Dave Love committed
584
  "Define NAME (a symbol) as a coding system with DOCSTRING and attributes.
585 586 587
The remaining arguments must come in pairs ATTRIBUTE VALUE.  ATTRIBUTE
may be any symbol.

Dave Love's avatar
Dave Love committed
588
The following attributes have special meanings.  Those labeled as
589
\"(required)\" should not be omitted.
590 591 592 593 594 595 596 597

`:mnemonic' (required)

VALUE is a character to display on mode line for the coding system.

`:coding-type' (required)

VALUE must be one of `charset', `utf-8', `utf-16', `iso-2022',
Dave Love's avatar
Dave Love committed
598
`emacs-mule', `shift-jis', `ccl', `raw-text', `undecided'.
599

Dave Love's avatar
Dave Love committed
600
`:eol-type'
601

Dave Love's avatar
Dave Love committed
602
VALUE is the EOL (end-of-line) format of the coding system.  It must be
603 604
one of `unix', `dos', `mac'.  The symbol `unix' means Unix-like EOL
\(i.e. single LF), `dos' means DOS-like EOL \(i.e. sequence of CR LF),
Eli Zaretskii's avatar
Eli Zaretskii committed
605 606
and `mac' means Mac-like EOL \(i.e. single CR).  If omitted, Emacs
detects the EOL format automatically when decoding.
607

Kenichi Handa's avatar
Kenichi Handa committed
608
`:charset-list'
609 610 611 612

VALUE must be a list of charsets supported by the coding system.  On
encoding by the coding system, if a character belongs to multiple
charsets in the list, a charset that comes earlier in the list is
Kenichi Handa's avatar
Kenichi Handa committed
613 614 615 616
selected.  If `:coding-type' is `iso-2022', VALUE may be `iso-2022',
which indicates that the coding system supports all ISO-2022 based
charsets.  If `:coding-type' is `emacs-mule', VALUE may be
`emacs-mule', which indicates that the coding system supports all
Dave Love's avatar
Dave Love committed
617
charsets that have the `:emacs-mule-id' property.
618

Dave Love's avatar
Dave Love committed
619
`:ascii-compatible-p'
620 621

If VALUE is non-nil, the coding system decodes all 7-bit bytes into
Dave Love's avatar
Dave Love committed
622
the corresponding ASCII characters, and encodes all ASCII characters
Dave Love's avatar
Dave Love committed
623
back to the corresponding 7-bit bytes.  VALUE defaults to nil.
624

Dave Love's avatar
Dave Love committed
625
`:decode-translation-table'
626 627 628

VALUE must be a translation table to use on decoding.

Dave Love's avatar
Dave Love committed
629
`:encode-translation-table'
630 631 632

VALUE must be a translation table to use on encoding.

Dave Love's avatar
Dave Love committed
633
`:post-read-conversion'
634 635 636

VALUE must be a function to call after some text is inserted and
decoded by the coding system itself and before any functions in
637 638 639 640
`after-insert-functions' are called.  This function is passed one
argument; the number of characters in the text to convert, with
point at the start of the text.  The function should leave point
the same, and return the new character count.
641 642 643 644

`:pre-write-conversion'

VALUE must be a function to call after all functions in
645 646 647
`write-region-annotate-functions' and `buffer-file-format' are
called, and before the text is encoded by the coding system
itself.  This function should convert the whole text in the
648
current buffer.  For backward compatibility, this function is
649
passed two arguments which can be ignored.
650 651 652 653 654 655

`:default-char'

VALUE must be a character.  On encoding, a character not supported by
the coding system is replaced with VALUE.

Kenichi Handa's avatar
Kenichi Handa committed
656 657 658 659 660
`:for-unibyte'

VALUE non-nil means that visiting a file with the coding system
results in a unibyte buffer.

661 662
`:mime-charset'

Dave Love's avatar
Dave Love committed
663 664
VALUE must be a symbol whose name is that of a MIME charset converted
to lower case.
665

Dave Love's avatar
Dave Love committed
666 667 668
`:mime-text-unsuitable'

VALUE non-nil means the `:mime-charset' property names a charset which
669
is unsuitable for the top-level media type \"text\".
Dave Love's avatar
Dave Love committed
670

671 672
`:flags'

Dave Love's avatar
Dave Love committed
673 674
VALUE must be a list of symbols that control the ISO-2022 converter.
Each must be a member of the list `coding-system-iso-2022-flags'
675 676 677 678 679
\(which see).  This attribute has a meaning only when `:coding-type'
is `iso-2022'.

`:designation'

Dave Love's avatar
Dave Love committed
680
VALUE must be a vector [G0-USAGE G1-USAGE G2-USAGE G3-USAGE].
681 682 683 684
GN-USAGE specifies the usage of graphic register GN as follows.

If it is nil, no charset can be designated to GN.

Dave Love's avatar
Dave Love committed
685
If it is a charset, the charset is initially designated to GN, and
686 687 688
never used by the other charsets.

If it is a list, the elements must be charsets, nil, 94, or 96.  GN
Dave Love's avatar
Dave Love committed
689 690 691 692 693
can be used by all the listed charsets.  If the list contains 94, any
iso-2022 charset whose code-space ranges are 94 long can be designated
to GN.  If the list contains 96, any charsets whose whose ranges are
96 long can be designated to GN.  If the first element is a charset,
that charset is initially designated to GN.
694 695 696 697 698

This attribute has a meaning only when `:coding-type' is `iso-2022'.

`:bom'

Dave Love's avatar
Dave Love committed
699
This attributes specifies whether the coding system uses a `byte order
700
mark'.  VALUE must be nil, t, or cons of coding systems whose
701
`:coding-type' is `utf-16' or `utf-8'.
702

703 704 705 706
If the value is nil, on decoding, don't treat the first two-byte as
BOM, and on encoding, don't produce BOM bytes.

If the value is t, on decoding, skip the first two-byte as BOM, and on
Paul Eggert's avatar
Paul Eggert committed
707
encoding, produce BOM bytes according to the value of `:endian'.
708

709
If the value is cons, on decoding, check the first two-byte.  If they
710
are 0xFE 0xFF, use the car part coding system of the value.  If they
711
are 0xFF 0xFE, use the cdr part coding system of the value.
712
Otherwise, treat them as bytes for a normal character.  On encoding,
Paul Eggert's avatar
Paul Eggert committed
713
produce BOM bytes according to the value of `:endian'.
714

715 716
This attribute has a meaning only when `:coding-type' is `utf-16' or
`utf-8'.
717 718 719

`:endian'

720 721
VALUE must be `big' or `little' specifying big-endian and
little-endian respectively.  The default value is `big'.
722 723 724 725 726

This attribute has a meaning only when `:coding-type' is `utf-16'.

`:ccl-decoder'

Dave Love's avatar
Dave Love committed
727 728 729
VALUE is a symbol representing the registered CCL program used for
decoding.  This attribute has a meaning only when `:coding-type' is
`ccl'.
730 731 732

`:ccl-encoder'

Dave Love's avatar
Dave Love committed
733 734 735
VALUE is a symbol representing the registered CCL program used for
encoding.  This attribute has a meaning only when `:coding-type' is
`ccl'."
736 737 738 739 740
  (let* ((common-attrs (mapcar 'list
			       '(:mnemonic
				 :coding-type
				 :charset-list
				 :ascii-compatible-p
741
				 :decode-translation-table
742 743 744 745
				 :encode-translation-table
				 :post-read-conversion
				 :pre-write-conversion
				 :default-char
746
				 :for-unibyte
747 748 749 750 751 752 753 754 755
				 :plist
				 :eol-type)))
	 (coding-type (plist-get props :coding-type))
	 (spec-attrs (mapcar 'list
			     (cond ((eq coding-type 'iso-2022)
				    '(:initial
				      :reg-usage
				      :request
				      :flags))
756 757
				   ((eq coding-type 'utf-8)
				    '(:bom))
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811
				   ((eq coding-type 'utf-16)
				    '(:bom
				      :endian))
				   ((eq coding-type 'ccl)
				    '(:ccl-decoder
				      :ccl-encoder
				      :valids))))))

    (dolist (slot common-attrs)
      (setcdr slot (plist-get props (car slot))))

    (dolist (slot spec-attrs)
      (setcdr slot (plist-get props (car slot))))

    (if (eq coding-type 'iso-2022)
	(let ((designation (plist-get props :designation))
	      (flags (plist-get props :flags))
	      (initial (make-vector 4 nil))
	      (reg-usage (cons 4 4))
	      request elt)
	  (dotimes (i 4)
	    (setq elt (aref designation i))
	    (cond ((charsetp elt)
		   (aset initial i elt)
		   (setq request (cons (cons elt i) request)))
		  ((consp elt)
		   (aset initial i (car elt))
		   (if (charsetp (car elt))
		       (setq request (cons (cons (car elt) i) request)))
		   (dolist (e (cdr elt))
		     (cond ((charsetp e)
			    (setq request (cons (cons e i) request)))
			   ((eq e 94)
			    (setcar reg-usage i))
			   ((eq e 96)
			    (setcdr reg-usage i))
			   ((eq e t)
			    (setcar reg-usage i)
			    (setcdr reg-usage i)))))))
	  (setcdr (assq :initial spec-attrs) initial)
	  (setcdr (assq :reg-usage spec-attrs) reg-usage)
	  (setcdr (assq :request spec-attrs) request)

	  ;; Change :flags value from a list to a bit-mask.
	  (let ((bits 0)
		(i 0))
	    (dolist (elt coding-system-iso-2022-flags)
	      (if (memq elt flags)
		  (setq bits (logior bits (lsh 1 i))))
	      (setq i (1+ i)))
	    (setcdr (assq :flags spec-attrs) bits))))

    ;; Add :name and :docstring properties to PROPS.
    (setq props
Dave Love's avatar
Dave Love committed
812 813
	  (cons :name (cons name (cons :docstring (cons (purecopy docstring)
							props)))))
814
    (setcdr (assq :plist common-attrs) props)
815
    (apply 'define-coding-system-internal
816
	   name (mapcar 'cdr (append common-attrs spec-attrs)))))
Karl Heuer's avatar
Karl Heuer committed
817

818
(defun coding-system-doc-string (coding-system)
819
  "Return the documentation string for CODING-SYSTEM."
820
  (plist-get (coding-system-plist coding-system) :docstring))
Karl Heuer's avatar
Karl Heuer committed
821 822

(defun coding-system-mnemonic (coding-system)
823
  "Return the mnemonic character of CODING-SYSTEM.
Dave Love's avatar
Dave Love committed
824
The mnemonic character of a coding system is used in mode line to
825
indicate the coding system.  If CODING-SYSTEM is nil, return ?=."
826
  (plist-get (coding-system-plist coding-system) :mnemonic))
Karl Heuer's avatar
Karl Heuer committed
827

828 829 830 831 832
(defun coding-system-type (coding-system)
  "Return the coding type of CODING-SYSTEM.
A coding type is a symbol indicating the encoding method of CODING-SYSTEM.
See the function `define-coding-system' for more detail."
  (plist-get (coding-system-plist coding-system) :coding-type))
833

834
(defun coding-system-charset-list (coding-system)
Dave Love's avatar
Dave Love committed
835
  "Return list of charsets supported by CODING-SYSTEM.
836 837 838
If CODING-SYSTEM supports all ISO-2022 charsets, return `iso-2022'.
If CODING-SYSTEM supports all emacs-mule charsets, return `emacs-mule'."
  (plist-get (coding-system-plist coding-system) :charset-list))
839

840 841 842
(defun coding-system-category (coding-system)
  "Return a category symbol of CODING-SYSTEM."
  (plist-get (coding-system-plist coding-system) :category))
843 844

(defun coding-system-get (coding-system prop)
Dave Love's avatar
Dave Love committed
845 846 847 848 849
  "Extract a value from CODING-SYSTEM's property list for property PROP.
For compatibility with Emacs 20/21, this accepts old-style symbols
like `mime-charset' as well as the current style like `:mime-charset'."
  (or (plist-get (coding-system-plist coding-system) prop)
      (if (not (keywordp prop))
Juanma Barranquero's avatar
Juanma Barranquero committed
850
	  ;; For backward compatibility.
Kenichi Handa's avatar
Kenichi Handa committed
851 852 853 854 855
	  (if (eq prop 'ascii-incompatible)
	      (not (plist-get (coding-system-plist coding-system)
			      :ascii-compatible-p))
	    (plist-get (coding-system-plist coding-system)
		       (intern (concat ":" (symbol-name prop))))))))
856

857 858 859
(defun coding-system-eol-type-mnemonic (coding-system)
  "Return the string indicating end-of-line format of CODING-SYSTEM."
  (let* ((eol-type (coding-system-eol-type coding-system))
860
	 (val (cond ((eq eol-type 0) eol-mnemonic-unix)
861 862
		    ((eq eol-type 1) eol-mnemonic-dos)
		    ((eq eol-type 2) eol-mnemonic-mac)
863
		    (t eol-mnemonic-undecided))))
864 865 866 867
    (if (stringp val)
	val
      (char-to-string val))))

868 869 870 871 872 873 874 875 876 877 878 879 880
(defun coding-system-lessp (x y)
  (cond ((eq x 'no-conversion) t)
	((eq y 'no-conversion) nil)
	((eq x 'emacs-mule) t)
	((eq y 'emacs-mule) nil)
	((eq x 'undecided) t)
	((eq y 'undecided) nil)
	(t (let ((c1 (coding-system-mnemonic x))
		 (c2 (coding-system-mnemonic y)))
	     (or (< (downcase c1) (downcase c2))
		 (and (not (> (downcase c1) (downcase c2)))
		      (< c1 c2)))))))

881 882
(defun coding-system-equal (coding-system-1 coding-system-2)
  "Return t if and only if CODING-SYSTEM-1 and CODING-SYSTEM-2 are identical.
883
Two coding systems are identical if both symbols are equal
884 885
or one is an alias of the other."
  (or (eq coding-system-1 coding-system-2)
886 887
      (and (equal (coding-system-plist coding-system-1)
		  (coding-system-plist coding-system-2))
888 889 890 891 892
	   (let ((eol-type-1 (coding-system-eol-type coding-system-1))
		 (eol-type-2 (coding-system-eol-type coding-system-2)))
	     (or (eq eol-type-1 eol-type-2)
		 (and (vectorp eol-type-1) (vectorp eol-type-2)))))))

893
(defun add-to-coding-system-list (coding-system)
Dave Love's avatar
Dave Love committed
894
  "Add CODING-SYSTEM to `coding-system-list' while keeping it sorted."
895 896 897 898 899 900 901 902 903 904 905 906 907
  (if (or (null coding-system-list)
	  (coding-system-lessp coding-system (car coding-system-list)))
      (setq coding-system-list (cons coding-system coding-system-list))
    (let ((len (length coding-system-list))
	  mid (tem coding-system-list))
      (while (> len 1)
	(setq mid (nthcdr (/ len 2) tem))
	(if (coding-system-lessp (car mid) coding-system)
	    (setq tem mid
		  len (- len (/ len 2)))
	  (setq len (/ len 2))))
      (setcdr tem (cons coding-system (cdr tem))))))

908
(defun coding-system-list (&optional base-only)
909
  "Return a list of all existing non-subsidiary coding systems.
Dave Love's avatar
Dave Love committed
910 911
If optional arg BASE-ONLY is non-nil, only base coding systems are
listed.  The value doesn't include subsidiary coding systems which are
912 913
made from bases and aliases automatically for various end-of-line
formats (e.g. iso-latin-1-unix, koi8-r-dos)."
914 915 916 917 918 919 920
  (let ((codings nil))
    (dolist (coding coding-system-list)
      (if (eq (coding-system-base coding) coding)
	  (if base-only
	      (setq codings (cons coding codings))
	    (dolist (alias (coding-system-aliases coding))
	      (setq codings (cons alias codings))))))
921 922
    codings))

923
(defconst char-coding-system-table nil
924 925
  "It exists just for backward compatibility, and the value is always nil.")
(make-obsolete-variable 'char-coding-system-table nil "23.1")
926

927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
(defun transform-make-coding-system-args (name type &optional doc-string props)
  "For internal use only.
Transform XEmacs style args for `make-coding-system' to Emacs style.
Value is a list of transformed arguments."
  (let ((mnemonic (string-to-char (or (plist-get props 'mnemonic) "?")))
	(eol-type (plist-get props 'eol-type))
	properties tmp)
    (cond
     ((eq eol-type 'lf) (setq eol-type 'unix))
     ((eq eol-type 'crlf) (setq eol-type 'dos))
     ((eq eol-type 'cr) (setq eol-type 'mac)))
    (if (setq tmp (plist-get props 'post-read-conversion))
	(setq properties (plist-put properties 'post-read-conversion tmp)))
    (if (setq tmp (plist-get props 'pre-write-conversion))
	(setq properties (plist-put properties 'pre-write-conversion tmp)))
    (cond
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
     ((eq type 'shift-jis)
      `(,name 1 ,mnemonic ,doc-string () ,properties ,eol-type))
     ((eq type 'iso2022) ; This is not perfect.
      (if (plist-get props 'escape-quoted)
	  (error "escape-quoted is not supported: %S"
		 `(,name ,type ,doc-string ,props)))
      (let ((g0 (plist-get props 'charset-g0))
      	    (g1 (plist-get props 'charset-g1))
      	    (g2 (plist-get props 'charset-g2))
      	    (g3 (plist-get props 'charset-g3))
      	    (use-roman
             (and
	      (eq (cadr (assoc 'latin-jisx0201
			       (plist-get props 'input-charset-conversion)))
		  'ascii)
	      (eq (cadr (assoc 'ascii
			       (plist-get props 'output-charset-conversion)))
		  'latin-jisx0201)))
            (use-oldjis
             (and
	      (eq (cadr (assoc 'japanese-jisx0208-1978
			       (plist-get props 'input-charset-conversion)))
		  'japanese-jisx0208)
	      (eq (cadr (assoc 'japanese-jisx0208
			       (plist-get props 'output-charset-conversion)))
		  'japanese-jisx0208-1978))))
	(if (charsetp g0)
	    (if (plist-get props 'force-g0-on-output)
		(setq g0 `(nil ,g0))
	      (setq g0 `(,g0 t))))
	(if (charsetp g1)
	    (if (plist-get props 'force-g1-on-output)
		(setq g1 `(nil ,g1))
	      (setq g1 `(,g1 t))))
	(if (charsetp g2)
	    (if (plist-get props 'force-g2-on-output)
		(setq g2 `(nil ,g2))
	      (setq g2 `(,g2 t))))
	(if (charsetp g3)
	    (if (plist-get props 'force-g3-on-output)
		(setq g3 `(nil ,g3))
	      (setq g3 `(,g3 t))))
	`(,name 2 ,mnemonic ,doc-string
	  (,g0 ,g1 ,g2 ,g3
	   ,(plist-get props 'short)
	   ,(not (plist-get props 'no-ascii-eol))
	   ,(not (plist-get props 'no-ascii-cntl))
	   ,(plist-get props 'seven)
	   t
	   ,(not (plist-get props 'lock-shift))
	   ,use-roman
	   ,use-oldjis
	   ,(plist-get props 'no-iso6429)
	   nil nil nil nil)
	,properties ,eol-type)))
     ((eq type 'big5)
      `(,name 3 ,mnemonic ,doc-string () ,properties ,eol-type))
1000
     ((eq type 'ccl)
1001
      `(,name 4 ,mnemonic ,doc-string
1002
	      (,(plist-get props 'decode) . ,(plist-get props 'encode))
1003
	      ,properties ,eol-type))
1004
     (t
1005
      (error "unsupported XEmacs style make-coding-style arguments: %S"
1006 1007
	     `(,name ,type ,doc-string ,props))))))

1008
(defun make-coding-system (coding-system type mnemonic doc-string
1009 1010 1011 1012
					 &optional
					 flags
					 properties
					 eol-type)
1013
  "Define a new coding system CODING-SYSTEM (symbol).
1014
This function is provided for backward compatibility."
1015
  (declare (obsolete define-coding-system "23.1"))
Juanma Barranquero's avatar
Juanma Barranquero committed
1016
  ;; For compatibility with XEmacs, we check the type of TYPE.  If it
Eli Zaretskii's avatar
Eli Zaretskii committed
1017 1018
  ;; is a symbol, perhaps, this function is called with XEmacs-style
  ;; arguments.  Here, try to transform that kind of arguments to
1019 1020 1021 1022 1023
  ;; Emacs style.
  (if (symbolp type)
      (let ((args (transform-make-coding-system-args coding-system type
						     mnemonic doc-string)))
	(setq coding-system (car args)
Dave Love's avatar
Dave Love committed
1024
	      type (nth 1 args)
1025 1026 1027 1028 1029 1030
	      mnemonic (nth 2 args)
	      doc-string (nth 3 args)
	      flags (nth 4 args)
	      properties (nth 5 args)
	      eol-type (nth 6 args))))

Kenichi Handa's avatar
Kenichi Handa committed
1031 1032 1033 1034 1035 1036 1037
  (setq type
	(cond ((eq type 0) 'emacs-mule)
	      ((eq type 1) 'shift-jis)
	      ((eq type 2) 'iso2022)
	      ((eq type 3) 'big5)
	      ((eq type 4) 'ccl)
	      ((eq type 5) 'raw-text)
1038
	      (t
Kenichi Handa's avatar
Kenichi Handa committed
1039 1040 1041 1042 1043 1044