[erlang-questions] Offset calculation in bit syntax
Thu Nov 22 21:55:39 CET 2007
I have to parse the following byte sequence where the first byte
indicates the payload length if the
payload length in 15 bytes or less, e.g. the 3 byte payload
x01 x02 x03
will be encoded as
0x23 x01 x02 x03
with 0x23 - 0x20 = 3, the length of the payload.
So when I parse it, I'd like to use a bit syntax similar to following:
decode(<< Len:8/unsigned, Rest:(Len - 16#20)/unsigned>>) ->
But this is an illegal bit size.
Is there an elegant way around this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions