comparison lisp/international/mule-cmds.el @ 50183:42387e68072a

(find-coding-systems-for-charsets): Use find-coding-systems-string instead of looking up char-coding-system-table.
author Kenichi Handa <handa@m17n.org>
date Tue, 18 Mar 2003 04:23:50 +0000
parents f2c182eeeda2
children 32b881425e3d
comparison
equal deleted inserted replaced
50182:32435942451c 50183:42387e68072a
481 element `undecided'." 481 element `undecided'."
482 (find-coding-systems-region string nil)) 482 (find-coding-systems-region string nil))
483 483
484 (defun find-coding-systems-for-charsets (charsets) 484 (defun find-coding-systems-for-charsets (charsets)
485 "Return a list of proper coding systems to encode characters of CHARSETS. 485 "Return a list of proper coding systems to encode characters of CHARSETS.
486 CHARSETS is a list of character sets." 486 CHARSETS is a list of character sets.
487 It actually checks at most the first 96 characters of each charset.
488 So, if a charset of dimension two is included in CHARSETS, the value may
489 contain a coding system that can't encode all characters of the charset."
487 (cond ((or (null charsets) 490 (cond ((or (null charsets)
488 (and (= (length charsets) 1) 491 (and (= (length charsets) 1)
489 (eq 'ascii (car charsets)))) 492 (eq 'ascii (car charsets))))
490 '(undecided)) 493 '(undecided))
491 ((or (memq 'eight-bit-control charsets) 494 ((or (memq 'eight-bit-control charsets)
492 (memq 'eight-bit-graphic charsets)) 495 (memq 'eight-bit-graphic charsets))
493 '(raw-text emacs-mule)) 496 '(raw-text emacs-mule))
494 (t 497 (t
495 (let ((codings t) 498 (let ((codings t)
496 charset l ll) 499 charset l str)
497 (while (and codings charsets) 500 (while (and codings charsets)
498 (setq charset (car charsets) charsets (cdr charsets)) 501 (setq charset (car charsets) charsets (cdr charsets))
499 (unless (eq charset 'ascii) 502 (unless (eq charset 'ascii)
500 (setq l (aref char-coding-system-table (make-char charset))) 503 (setq str (make-string 96 32))
504 (if (= (charset-dimension charset) 1)
505 (if (= (charset-chars charset) 96)
506 (dotimes (i 96)
507 (aset str i (make-char charset (+ i 32))))
508 (dotimes (i 94)
509 (aset str i (make-char charset (+ i 33)))))
510 (if (= (charset-chars charset) 96)
511 (dotimes (i 96)
512 (aset str i (make-char charset 32 (+ i 32))))
513 (dotimes (i 94)
514 (aset str i (make-char charset 33 (+ i 33))))))
515 (setq l (find-coding-systems-string str))
501 (if (eq codings t) 516 (if (eq codings t)
502 (setq codings l) 517 (setq codings l)
503 (let ((ll nil)) 518 (let ((ll nil))
504 (while codings 519 (dolist (elt codings)
505 (if (memq (car codings) l) 520 (if (memq elt l)
506 (setq ll (cons (car codings) ll))) 521 (setq ll (cons elt ll))))
507 (setq codings (cdr codings)))
508 (setq codings ll))))) 522 (setq codings ll)))))
509 (append codings 523 codings))))
510 (char-table-extra-slot char-coding-system-table 0))))))
511 524
512 (defun find-multibyte-characters (from to &optional maxcount excludes) 525 (defun find-multibyte-characters (from to &optional maxcount excludes)
513 "Find multibyte characters in the region specified by FROM and TO. 526 "Find multibyte characters in the region specified by FROM and TO.
514 If FROM is a string, find multibyte characters in the string. 527 If FROM is a string, find multibyte characters in the string.
515 The return value is an alist of the following format: 528 The return value is an alist of the following format: