aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2002-05-26 17:22:23 +0000
committerDave Love2002-05-26 17:22:23 +0000
commitbc304a2060d789d5ab12a72e86bdf6f92e553cd9 (patch)
tree3a0344aa1fc5cf64f6a191ca6bf7dcd62e2951d5
parent8285fa96b16dededbdc6654f77b5b5a32e562abb (diff)
downloademacs-bc304a2060d789d5ab12a72e86bdf6f92e553cd9.tar.gz
emacs-bc304a2060d789d5ab12a72e86bdf6f92e553cd9.zip
(encode-coding-char): Use
find-coding-systems-string. Don't use make-char.
-rw-r--r--lisp/international/mule-cmds.el15
1 files changed, 6 insertions, 9 deletions
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."
398 (if (eq (coding-system-type base) 2) 398 (if (eq (coding-system-type base) 2)
399 ;; For ISO based coding systems, prefer 399 ;; For ISO based coding systems, prefer
400 ;; one that doesn't use escape sequences. 400 ;; one that doesn't use escape sequences.
401 ;; Fixme: coding-system-spec
401 (let* ((extra-spec (coding-system-spec base)) 402 (let* ((extra-spec (coding-system-spec base))
402 (flags (aref extra-spec 3))) 403 (flags (aref extra-spec 3)))
403 (if (/= (logand flags #x40) 0) 404 (if (/= (logand flags #x40) 0)
@@ -2023,18 +2024,14 @@ It can be retrieved with `(get-char-code-property CHAR PROPNAME)'."
2023(defun encode-coding-char (char coding-system) 2024(defun encode-coding-char (char coding-system)
2024 "Encode CHAR by CODING-SYSTEM and return the resulting string. 2025 "Encode CHAR by CODING-SYSTEM and return the resulting string.
2025If CODING-SYSTEM can't safely encode CHAR, return nil." 2026If CODING-SYSTEM can't safely encode CHAR, return nil."
2026 (let ((str1 (string-as-multibyte (char-to-string char))) 2027 (let ((str1 (string-as-multibyte (string char)))
2027 (str2 (string-as-multibyte (make-string 2 char))) 2028 (str2 (string-as-multibyte (string char char)))
2028 (safe-chars (and coding-system
2029 (coding-system-get coding-system 'safe-chars)))
2030 (charset (char-charset char))
2031 enc1 enc2 i1 i2) 2029 enc1 enc2 i1 i2)
2032 (when (or (eq safe-chars t) 2030 (when (memq (coding-system-base coding-system)
2033 (eq charset 'ascii) 2031 (find-coding-systems-string str1))
2034 (and safe-chars (aref safe-chars char)))
2035 ;; We must find the encoded string of CHAR. But, just encoding 2032 ;; We must find the encoded string of CHAR. But, just encoding
2036 ;; CHAR will put extra control sequences (usually to designate 2033 ;; CHAR will put extra control sequences (usually to designate
2037 ;; ASCII charaset) at the tail if type of CODING is ISO 2022. 2034 ;; ASCII charset) at the tail if type of CODING is ISO 2022.
2038 ;; To exclude such tailing bytes, we at first encode one-char 2035 ;; To exclude such tailing bytes, we at first encode one-char
2039 ;; string and two-char string, then check how many bytes at the 2036 ;; string and two-char string, then check how many bytes at the
2040 ;; tail of both encoded strings are the same. 2037 ;; tail of both encoded strings are the same.