UTF-8 #
The well-formed byte sequences are those of the Unicode Standard, Table 3-7. Encoding, strict
decoding and validation are core's, which are fast. Ill-formed input goes through the decoder of
UTF8.decodeIter: decode reports the byte offset of the first maximal subpart of an ill-formed
byte sequence, and decodeLossy replaces each maximal subpart with U+FFFD, following the
recommended practice of the Standard, Section 3.9. Core's String.fromUTF8Lossy replaces each run
of ill-formed bytes instead, so it can give fewer U+FFFD.
The UTF-8 bytes of c, one to four of them.
Equations
- Unicode.UTF8.encodeChar c = ScalarArray.UInt8Array.ofFn fun (i : Fin c.utf8Size) => Unicode.Encoder.unit { } c ↑i
Instances For
The UTF-8 encoding of s.
Equations
Instances For
Decodes the UTF-8 bytes of b, or returns an error with the byte offset of the first maximal
subpart of an ill-formed byte sequence.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Decodes the UTF-8 bytes of b, or returns none if b is ill-formed.
Equations
Instances For
Decodes the UTF-8 bytes of b, panicking if b is ill-formed.
Equations
Instances For
Decodes the UTF-8 bytes of b, replacing each maximal subpart of an ill-formed byte sequence
with U+FFFD.
Equations
- Unicode.UTF8.decodeLossy b = match String.fromUTF8? b with | some s => s | none => Unicode.Decoder.foldLossy { } String.push "" b.toUInt8Array.iter
Instances For
Whether b is well-formed UTF-8.