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
(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.
\f