Binary Output

The io.aviso.binary namespace provides support output of binary data.

Binary data is represented using the protocol BinaryData; this protocol is extended on byte arrays, on String, and on nil. BinaryData is simply a randomly accessible collection of bytes, with a known length.

(write-binary "Choose immutability and see where it takes you.")
0000: 43 68 6F 6F 73 65 20 69 6D 6D 75 74 61 62 69 6C 69 74 79 20 61 6E 64 20 73 65 65 20 77 68 65 72
0020: 65 20 69 74 20 74 61 6B 65 73 20 79 6F 75 2E
_images/write-binary.png

Alternately, format-binary will return the formatted binary output string.

You can also compare two binary data values with write-binary-delta:

_images/binary-diff.png

If the two data are of different lengths, the shorter one is padded with -- to make up the difference.

As with write-binary, there’s a format-binary-delta.