From: Dave Love Date: Sun, 26 May 2002 17:22:23 +0000 (+0000) Subject: (encode-coding-char): Use X-Git-Tag: emacs-pretest-23.0.90~8295^2~1864^2~751 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bc304a2060d789d5ab12a72e86bdf6f92e553cd9;p=emacs.git (encode-coding-char): Use find-coding-systems-string. Don't use make-char. --- diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index f8ab55fc2bf..4880d9cb1d0 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -398,6 +398,7 @@ non-nil, it is used to sort CODINGS in the different way than above." (if (eq (coding-system-type base) 2) ;; For ISO based coding systems, prefer ;; one that doesn't use escape sequences. + ;; Fixme: coding-system-spec (let* ((extra-spec (coding-system-spec base)) (flags (aref extra-spec 3))) (if (/= (logand flags #x40) 0) @@ -2023,18 +2024,14 @@ It can be retrieved with `(get-char-code-property CHAR PROPNAME)'." (defun encode-coding-char (char coding-system) "Encode CHAR by CODING-SYSTEM and return the resulting string. If CODING-SYSTEM can't safely encode CHAR, return nil." - (let ((str1 (string-as-multibyte (char-to-string char))) - (str2 (string-as-multibyte (make-string 2 char))) - (safe-chars (and coding-system - (coding-system-get coding-system 'safe-chars))) - (charset (char-charset char)) + (let ((str1 (string-as-multibyte (string char))) + (str2 (string-as-multibyte (string char char))) enc1 enc2 i1 i2) - (when (or (eq safe-chars t) - (eq charset 'ascii) - (and safe-chars (aref safe-chars char))) + (when (memq (coding-system-base coding-system) + (find-coding-systems-string str1)) ;; We must find the encoded string of CHAR. But, just encoding ;; CHAR will put extra control sequences (usually to designate - ;; ASCII charaset) at the tail if type of CODING is ISO 2022. + ;; ASCII charset) at the tail if type of CODING is ISO 2022. ;; To exclude such tailing bytes, we at first encode one-char ;; string and two-char string, then check how many bytes at the ;; tail of both encoded strings are the same.