On Fri, 30 Sep 2022, Zhu Zihao <all_but_l...@163.com> wrote:
> Hi, dear Guile users!
>
> I'm using Guile to play around with some binaries. In Guile, the
> bytevector prints its content in decimal format. Just like:
>
> #vu8(255 255 255 255)
>
> But, it's always more convenient if its content is printed in hex format
> like
>
> #vu8(#xff #xff #xff #xff)

Right.  The Guile printer has no option of that sort yet.  Quickly I
would think that this should work:
--8<---------------cut here---------------start------------->8---
(use-modules (oop goops))

(define-method (display (bv <bytevector>) port)
  (format port "#vu8(~{#x~x~})" (bytevector->u8-list bv)))
--8<---------------cut here---------------end--------------->8---

but I haven't tested it.

-- 
Olivier Dion
oldiob.dev

Reply via email to