Encoding protocol
Factor handbook » Input and output » I/O encodings

Prev:Encoding and decoding strings
Next:encode-output ( encoding -- )


There are two parts to implementing a new encoding. First, methods for creating an encoded or decoded stream must be provided. These have defaults, however, which wrap a stream in an encoder or decoder wrapper with the given encoding descriptor.
<encoder> ( stream encoding -- newstream )

<decoder> ( stream encoding -- newstream )


If an encoding might be contained in the code slot of an encoder or decoder tuple, then the following methods must be implemented to read or write one code point from a stream:
decode-char ( stream encoding -- char/f )

encode-char ( char stream encoding -- )


See also
An introduction to encodings