Encoding scheme iterators #
An encoding scheme is a decoder from bytes to characters and an encoder from characters to bytes,
in one layer. EncodingScheme.decodeIter e reads the byte order mark or signature of e, if it
has one, then decodes the characters after it; EncodingScheme.encodeIter e writes the mark, then
the characters. Positions are byte offsets in the input, it.decodeBase.toUInt8Slice.start for a
byte slice, and ill-formed input of every kind is reported by the one decoder: an incomplete code
unit at the end as well as an unpaired surrogate or a code unit that is not a scalar value.
As a decoder, e decodes the characters after the mark: utf8BOM decodes as utf8, and
utf16 o and utf32 o decode in byte order o. decodeIter gives utf16 o and utf32 o the
byte order that the mark tells.
Decodes one character from the bytes of it in scheme e, after any byte order mark or signature.
Calls yield with the character and the iterator after it, error with the iterator after the
ill-formed input, or done at the end of the input.
Equations
- Unicode.EncodingScheme.utf8.decodeChar it yield error done = Unicode.UTF8.decodeChar it yield error done
- Unicode.EncodingScheme.utf8BOM.decodeChar it yield error done = Unicode.UTF8.decodeChar it yield error done
- Unicode.EncodingScheme.utf16BE.decodeChar it yield error done = Unicode.EncodingScheme.decodeChar16✝ Unicode.ByteOrder.big it yield error done
- Unicode.EncodingScheme.utf16LE.decodeChar it yield error done = Unicode.EncodingScheme.decodeChar16✝ Unicode.ByteOrder.little it yield error done
- (Unicode.EncodingScheme.utf16 o).decodeChar it yield error done = Unicode.EncodingScheme.decodeChar16✝ o it yield error done
- Unicode.EncodingScheme.utf32BE.decodeChar it yield error done = Unicode.EncodingScheme.decodeChar32✝ Unicode.ByteOrder.big it yield error done
- Unicode.EncodingScheme.utf32LE.decodeChar it yield error done = Unicode.EncodingScheme.decodeChar32✝ Unicode.ByteOrder.little it yield error done
- (Unicode.EncodingScheme.utf32 o).decodeChar it yield error done = Unicode.EncodingScheme.decodeChar32✝ o it yield error done
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Decodes the bytes of it in scheme e, stopping at the first ill-formed input. A byte order mark
or signature of e at the start is skipped, and for utf16 o and utf32 o the mark tells the byte
order; without one, the byte order is o.
A for loop or fold over the result ends at ill-formed input just as at the end of the input. To
tell them apart, fold with decodeFold, which also returns the iterator where decoding stopped, and
check decodeError? there, find the first ill-formed input ahead with decodeFailure?, or decode
with decodeIterLossy instead.
Equations
- e.decodeIter it = match Unicode.EncodingScheme.start✝ e it with | (e, it) => Unicode.Decoder.iter e it
Instances For
Decodes the bytes of it in scheme e like decodeIter, replacing each ill-formed input
with U+FFFD.
Equations
- e.decodeIterLossy it = match Unicode.EncodingScheme.start✝ e it with | (e, it) => Unicode.Decoder.iterLossy e it
Instances For
Encodes the characters of it as bytes in scheme e, starting with the byte order mark or
signature of e if it has one.
Equations
- One or more equations did not get rendered due to their size.