|
From: | Stefan Monnier |
Subject: | Re: Byte swapping and bindat |
Date: | Fri, 10 Jun 2022 09:32:31 -0400 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
> Is there a way to specify a bindat type with fields whose endianess > depends on an external parameter (or another field of the type?) I'm so glad you asked: (let* ((threshold 32) (type (bindat-type (kind uint 8) (length sint 32 (> kind threshold))))) (list (bindat-unpack type "\x10\x00\x00\x01\x01") (bindat-unpack type "\x80\x00\x00\x01\x01"))) => (((kind . 16) (length . 257)) ((kind . 128) (length . 16842752))) That's one of the benefits of the new Bindat :-) Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |