Binary and text streams
Factor handbook » Input and output » Streams » Stream protocol

Next:stream-read1 ( stream -- elt )

A word which outputs the stream element type:
stream-element-type ( stream -- type )

Stream element types:


The stream element type is the data type read and written by stream-read1 and stream-write1.

Binary streams have an element type of +byte+. Elements are integers in the range [0,255], representing bytes. Reading a sequence of elements produces a byte-array. Any object implementing the >c-ptr and byte-length generic words can be written to a binary stream.

Character streams have an element type of +character+. Elements are non-negative integers, representing Unicode code points. Only instances of the string class can be read or written on a character stream.

Most external streams are binary streams, and can be wrapped in string streams once a suitable encoding has been provided; see I/O encodings.