This commit is contained in:
Tony Garnock-Jones 2023-06-27 21:25:09 +02:00
parent 9f556fd9e6
commit 829ff5c3c5
1 changed files with 8 additions and 5 deletions

View File

@ -153,19 +153,22 @@ points, while for `ByteString` it is the raw data contained within the
Encoded data of length 7 bytes or shorter is represented as an immediate
`Ref` with tag 4 (`String`), 6 (`ByteString`) or 8 (`Symbol`). The lower 4
bits of the 60-bit payload are the length of the encoded data; the upper 56
bits are 7 bytes of data, with the first data byte in the uppermost byte.
bits are 7 bytes of data, with the first data byte in the lowest byte, so
that the order of data bytes in memory in an immediate encoding matches the
order in a `Buf` encoding.
Data longer than 7 bytes is represented with a `Ref` with tag 5, 7 or 9
pointing to a `Buf` containing the bytes of encoded data. Empty values
(length 0) *MUST* be encoded using immediate `Ref` form.
(length 0) *MUST* be encoded using pointer `Ref` form with special offset
zero.
For example,
Value Ref (64-bit) Buf (hex bytes)
----------------------------------------- ---------------- ----------------
"" 0000000000000004 -
#"" 0000000000000006 -
|| 0000000000000008 -
"" 0000000000000005 -
#"" 0000000000000007 -
|| 0000000000000009 -
"Hello" 48656C6C6F000054 -
"a\0a" 6100610000000034 -