[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Towards a cleaner build: hexl
From: |
Eli Zaretskii |
Subject: |
Re: Towards a cleaner build: hexl |
Date: |
Fri, 17 May 2019 16:26:31 +0300 |
> From: Lars Ingebrigtsen <address@hidden>
> Date: Fri, 17 May 2019 14:45:23 +0200
>
> (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.
>
> And here we really, really want the internal byte representation of the
> multibyte string, so I think the code is correct and just needs a
> with-no-warnings? I mean,
>
> (with-suppressed-warnings ((obsolete string-as-unibyte))
> (string-as-unibyte (char-to-string ch)))
Howe about this instead:
(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 " "))))
Does this work?
- Re: Towards a cleaner build: arc-mode, (continued)
- Re: Towards a cleaner build: arc-mode, Lars Ingebrigtsen, 2019/05/18
- Re: Towards a cleaner build: arc-mode, Eli Zaretskii, 2019/05/18
- Re: Towards a cleaner build: arc-mode, Lars Ingebrigtsen, 2019/05/18
- Re: Towards a cleaner build: arc-mode, Lars Ingebrigtsen, 2019/05/19
- Re: Towards a cleaner build: arc-mode, Eli Zaretskii, 2019/05/19
Re: Towards a cleaner build: ehelp, Lars Ingebrigtsen, 2019/05/17
Re: Towards a cleaner build: hexl, Lars Ingebrigtsen, 2019/05/17
Re: Towards a cleaner build: custom, Lars Ingebrigtsen, 2019/05/18
Re: Towards a cleaner build: frameset, Lars Ingebrigtsen, 2019/05/18