diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2019-05-28 19:33:20 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2019-05-28 19:33:20 -0400 |
commit | 96a0d4fe41905e84a109f25848c1fb7c561a737c (patch) | |
tree | 4aab966f1e6b3668cd3c1e7b473e0b5a679c83e8 /lisp/international | |
parent | 997ac9f829059bf37c81fd586910c834394951e6 (diff) | |
download | emacs-96a0d4fe41905e84a109f25848c1fb7c561a737c.tar.gz emacs-96a0d4fe41905e84a109f25848c1fb7c561a737c.tar.bz2 emacs-96a0d4fe41905e84a109f25848c1fb7c561a737c.zip |
* lisp/international/mule-cmds.el (encode-coding-char): Fix ASCII case
Don't bother with string-as-multibyte since `string` already returns
multibyte when needed. Don't forget to encode when the string is
ASCII, e.g. for ebcdic case and to make sure we always return
a unibyte string.
* test/lisp/international/mule-tests.el (mule-cmds-tests--encode-ebcdic):
New test.
Diffstat (limited to 'lisp/international')
-rw-r--r-- | lisp/international/mule-cmds.el | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 27296ecfb2c..ecdab5e931d 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el @@ -2913,13 +2913,13 @@ If there's no description string for VALUE, return nil." If CODING-SYSTEM can't safely encode CHAR, return nil. The 3rd optional argument CHARSET, if non-nil, is a charset preferred on encoding." - (let* ((str1 (string-as-multibyte (string char))) - (str2 (string-as-multibyte (string char char))) + (let* ((str1 (string char)) + (str2 (string char char)) (found (find-coding-systems-string str1)) enc1 enc2 i1 i2) - (if (and (consp found) - (eq (car found) 'undecided)) - str1 + (if (eq (car-safe found) 'undecided) ;Aka (not (multibyte-string-p str1)) + ;; `char' is ASCII. + (encode-coding-string str1 coding-system) (when (memq (coding-system-base coding-system) found) ;; We must find the encoded string of CHAR. But, just encoding ;; CHAR will put extra control sequences (usually to designate |