[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master a7a730e 2/2: (hexl-insert-multibyte-char): Avoid us
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master a7a730e 2/2: (hexl-insert-multibyte-char): Avoid using `string-as-unibyte' |
Date: |
Sat, 18 May 2019 01:25:25 -0400 (EDT) |
branch: master
commit a7a730e32a62790121566d756df53fbe250c1eb0
Author: Eli Zaretskii <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
(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.
---
lisp/hexl.el | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/lisp/hexl.el b/lisp/hexl.el
index c1c2d70..ee5a9c0 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -877,17 +877,18 @@ and their encoded form is inserted byte by byte."
"0x%x -- invalid character code; use \\[hexl-insert-hex-string]"
ch))
(t
- (let ((encoded (encode-coding-char ch coding))
- (internal (string-as-unibyte (char-to-string ch)))
- internal-hex)
- ;; If encode-coding-char returns nil, it means our character
- ;; cannot be safely encoded with buffer-file-coding-system.
- ;; In that case, we offer to insert the internal representation
- ;; of that character, byte by byte.
- (when (null encoded)
- (setq internal-hex
- (mapconcat (function (lambda (c) (format "%x" c)))
- internal " "))
+ (let ((encoded (encode-coding-char ch coding))
+ (internal (char-to-string ch))
+ internal-hex)
+ ;; If encode-coding-char returns nil, it means our character
+ ;; cannot be safely encoded with buffer-file-coding-system.
+ ;; In that case, we offer to insert the internal representation
+ ;; of that character, byte by byte.
+ (when (null encoded)
+ (setq internal (encode-coding-string internal 'utf-8-emacs)
+ internal-hex
+ (mapconcat (function (lambda (c) (format "%x" c)))
+ internal " "))
(if (yes-or-no-p
(format-message
"Insert char 0x%x's internal representation \"%s\"? "