[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 96a0d4f: * lisp/international/mule-cmds.el (encode-
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 96a0d4f: * lisp/international/mule-cmds.el (encode-coding-char): Fix ASCII case |
Date: |
Tue, 28 May 2019 19:33:24 -0400 (EDT) |
branch: master
commit 96a0d4fe41905e84a109f25848c1fb7c561a737c
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* 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.
---
lisp/international/mule-cmds.el | 10 +++++-----
test/lisp/international/mule-tests.el | 4 ++++
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 27296ec..ecdab5e 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
diff --git a/test/lisp/international/mule-tests.el
b/test/lisp/international/mule-tests.el
index 4c937ca..678cbc2 100644
--- a/test/lisp/international/mule-tests.el
+++ b/test/lisp/international/mule-tests.el
@@ -36,6 +36,10 @@
(find-auto-coding "" (buffer-size)))
'(utf-8 . :coding)))))
+(ert-deftest mule-cmds-tests--encode-ebcdic ()
+ (should (equal (encode-coding-char ?a 'ebcdic-int) "\201"))
+ (should (not (multibyte-string-p (encode-coding-char ?a 'utf-8)))))
+
;; Stop "Local Variables" above causing confusion when visiting this file.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 96a0d4f: * lisp/international/mule-cmds.el (encode-coding-char): Fix ASCII case,
Stefan Monnier <=