Vocabulary
io.encodings

Inputs
streaman underlying input stream
encodingAn encoding descriptor tuple


Outputs
char/fa code point or f


Generic word contract
Reads a single code point from the underlying stream, interpreting it by the encoding. Returns f if the stream end is reached.

Notes
Calling this word directly is not necessary in most cases. Higher-level words call it automatically.

See also
encode-char

Definition

GENERIC: decode-char ( stream encoding -- char/f )


Methods







M:: euc decode-char ( stream encoding -- char/f )
stream stream-read1 {
{ [ dup not ] [ drop f ] }
{
[ dup euc-multibyte? ]
[ stream encoding decode-multibyte ]
}
[ encoding table>> at ]
} cond ;






M:: iso2022-state decode-char ( stream encoding -- char/f )
stream stream-read1 {
{
22
[
stream read-escape
[ encoding type<< stream encoding decode-char ]
[ replacement-char ] if*
]
}
{ f [ f ] }
[
encoding type>> double-width? [
stream stream-read1
[ 2byte-array be> encoding finish-decode ]
[ drop replacement-char ] if*
] [ encoding finish-decode ] if
]
} case ;