aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2000-10-30 01:32:44 +0000
committerKenichi Handa2000-10-30 01:32:44 +0000
commitcc57cc54dc05b73cb434867f18964c8c9b256689 (patch)
tree727a2ffda4ecd179d0effa2b9499b7092be86b5c
parente98a6f1c26b9b334828a21a573b24a5f8b7e194c (diff)
downloademacs-cc57cc54dc05b73cb434867f18964c8c9b256689.tar.gz
emacs-cc57cc54dc05b73cb434867f18964c8c9b256689.zip
(decode-char, encode-char): New functions.
(make-coding-system): Accept a symbol of translation table as a value of property `safe-chars'.
-rw-r--r--lisp/international/mule.el64
1 files changed, 62 insertions, 2 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index a5d8adaaf1f..922a9cf7d95 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -288,6 +288,63 @@ See also the documentation of make-char."
288 (and (or (= (nth 1 l) 0) (eq (nth 2 l) 0)) 288 (and (or (= (nth 1 l) 0) (eq (nth 2 l) 0))
289 (not (eq (car l) 'composition)))))) 289 (not (eq (car l) 'composition))))))
290 290
291(defun decode-char (ccs code-point &optional restriction)
292 "Return a character specified by coded character set CCS and CODE-POINT in it.
293Return nil if such a character is not supported.
294Currently, supported coded character set is `ucs' (ISO/IEC
29510646: Universal Multi-Octet Coded Character Set) only.
296
297Optional argument RESTRICTION specifies a way to map the pair of CCS
298and CODE-POINT to a chracter. Currently not supported and just ignored."
299 (cond ((eq ccs 'ucs)
300 (cond ((< code-point 128)
301 code-point)
302 ((< code-point 256)
303 (make-char 'latin-iso8859-1 code-point))
304 ((< code-point #x2500)
305 (setq code-point (- code-point #x0100))
306 (make-char 'mule-unicode-0100-24ff
307 (+ (/ code-point 96) 32) (+ (% code-point 96) 32)))
308 ((< code-point #x33ff)
309 (setq code-point (- code-point #x2500))
310 (make-char 'mule-unicode-2500-33ff
311 (+ (/ code-point 96) 32) (+ (% code-point 96) 32)))
312 ((and (>= code-point #xe000) (< code-point #x10000))
313 (setq code-point (- code-point #xe000))
314 (make-char 'mule-unicode-e000-ffff
315 (+ (/ code-point 96) 32) (+ (% code-point 96) 32)))
316 ))))
317
318(defun encode-char (char ccs &optional restriction)
319 "Return a code-point in coded character set CCS that corresponds to CHAR.
320Return nil if CHAR is not included in CCS.
321Currently, supported coded character set is `ucs' (ISO/IEC
32210646: Universal Multi-Octet Coded Character Set) only.
323Return a Unicode character code for CHAR.
324Charset of CHAR should be one of these:
325 ascii, latin-iso8859-1, mule-unicode-0100-24ff, mule-unicode-2500-33ff,
326 mule-unicode-e000-ffff
327Otherwise, return nil.
328
329Optional argument RESTRICTION specifies a way to map CHAR to a
330code-point in CCS. Currently not supported and just ignored."
331 (let* ((split (split-char char))
332 (charset (car split)))
333 (cond ((eq ccs 'ucs)
334 (cond ((eq charset 'ascii)
335 char)
336 ((eq charset 'latin-iso8859-1)
337 (+ (nth 1 split) 128))
338 ((eq charset 'mule-unicode-0100-24ff)
339 (+ #x0100 (+ (* (- (nth 1 split) 32) 96)
340 (- (nth 2 split) 32))))
341 ((eq charset 'mule-unicode-2500-33ff)
342 (+ #x2500 (+ (* (- (nth 1 split) 32) 96)
343 (- (nth 2 split) 32))))
344 ((eq charset 'mule-unicode-e000-ffff)
345 (+ #xe000 (+ (* (- (nth 1 split) 32) 96)
346 (- (nth 2 split) 32)))))))))
347
291 348
292;; Coding system staffs 349;; Coding system staffs
293 350
@@ -781,8 +838,11 @@ a value of `safe-charsets' in PLIST."
781 (setq prop (car (car l)) val (cdr (car l)) l (cdr l)) 838 (setq prop (car (car l)) val (cdr (car l)) l (cdr l))
782 (if (eq prop 'safe-chars) 839 (if (eq prop 'safe-chars)
783 (progn 840 (progn
784 (setq val safe-chars) 841 (if (and (symbolp val)
785 (register-char-codings coding-system safe-chars))) 842 (get val 'translation-table))
843 (setq safe-chars (get val 'translation-table)))
844 (register-char-codings coding-system safe-chars)
845 (setq val safe-chars)))
786 (plist-put plist prop val))) 846 (plist-put plist prop val)))
787 ;; The property `coding-category' may have been set differently 847 ;; The property `coding-category' may have been set differently
788 ;; through PROPERTIES. 848 ;; through PROPERTIES.