Function write-byte

Syntax:

write-byte byte stream β†’ byte

Arguments and Values:

byteβ€”an integer of the stream element type of stream.

streamβ€”a binary output stream.

Description:

22.3.2 4write-byte writes one byte, byte, to stream.

The size of the byte written depends on the {\bf :element-type} argument from \funref{open} or \macref{with-open-file}. Unless the byte size of that element type is one, two, or four bits, each call to \funref{write-byte} generates an integral number of 8-bit bytes, namely the minimum number necessary to hold the number of bits indicated by the given element type. If the byte size of the element type is one, two, or four bits, then as many elements as possible (eight, four, or two respectively) are packed into each 8-bit byte.

Examples:

 (with-open-file (s "temp-bytes" 
                    :direction :output
                    :element-type 'unsigned-byte)
    (write-byte 101 s)) β†’ 101

Side Effects:

stream is modified.

Affected By:

The element type of the stream.

Exceptional Situations:

Should signal an error of type type-error if stream is not a stream. Should signal an error of type error if stream is not a binary output stream.

Might signal an error of type type-error if byte is not an integer of the stream element type of stream.

See Also:

read-byte, write-char, write-sequence

Notes:

None.