Книги автора: Practical Common Lisp
Книга: Practical Common Lisp
Reading Binary Data
Reading Binary Data
By default OPEN
returns character streams, which translate the underlying bytes to characters according to a particular character-encoding scheme.[152] To read the raw bytes, you need to pass OPEN
an :element-type
argument of '(unsigned-byte 8)
.[153] You can pass the resulting stream to the function READ-BYTE
, which will return an integer between 0 and 255 each time it's called. READ-BYTE
, like the character-reading functions, also accepts optional arguments to specify whether it should signal an error if called at the end of the file and what value to return if not. In Chapter 24 you'll build a library that allows you to conveniently read structured binary data using READ-BYTE
.[154]