Commit a7a730e3 authored by Eli Zaretskii's avatar Eli Zaretskii Committed by Lars Ingebrigtsen

(hexl-insert-multibyte-char): Avoid using `string-as-unibyte'

* lisp/hexl.el (hexl-insert-multibyte-char): Avoid using
`string-as-unibyte' in the fallback case.
parent 635d7a39
Pipeline #1710 failed with stage
in 57 minutes and 32 seconds
...@@ -877,17 +877,18 @@ and their encoded form is inserted byte by byte." ...@@ -877,17 +877,18 @@ and their encoded form is inserted byte by byte."
"0x%x -- invalid character code; use \\[hexl-insert-hex-string]" "0x%x -- invalid character code; use \\[hexl-insert-hex-string]"
ch)) ch))
(t (t
(let ((encoded (encode-coding-char ch coding)) (let ((encoded (encode-coding-char ch coding))
(internal (string-as-unibyte (char-to-string ch))) (internal (char-to-string ch))
internal-hex) internal-hex)
;; If encode-coding-char returns nil, it means our character ;; If encode-coding-char returns nil, it means our character
;; cannot be safely encoded with buffer-file-coding-system. ;; cannot be safely encoded with buffer-file-coding-system.
;; In that case, we offer to insert the internal representation ;; In that case, we offer to insert the internal representation
;; of that character, byte by byte. ;; of that character, byte by byte.
(when (null encoded) (when (null encoded)
(setq internal-hex (setq internal (encode-coding-string internal 'utf-8-emacs)
(mapconcat (function (lambda (c) (format "%x" c))) internal-hex
internal " ")) (mapconcat (function (lambda (c) (format "%x" c)))
internal " "))
(if (yes-or-no-p (if (yes-or-no-p
(format-message (format-message
"Insert char 0x%x's internal representation \"%s\"? " "Insert char 0x%x's internal representation \"%s\"? "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment