UTF-8 validation and decoding.
Functions
decode | The scalar starting at start and the index just past it; None for an overlong encoding, a surrogate, a truncated sequence, a scalar outside Unicode, or a start past the end. |
validate | Whether all of bytes is UTF-8 that decode reads, scalar after scalar to the end. |
width | How many bytes the UTF-8 form of code takes; 0 when code is not a Unicode scalar (a surrogate, or past U+10FFFF). |
encode | Writes the UTF-8 form of code to out. |
Function declarations
fn decodesource
forall C, S where ReadBytes[C, S], Copy[S].
fn decode(&cx: C, bytes: S, start: usize) -> Option[(u32, usize)] { ... }
The scalar starting at start and the index just past it; None for an overlong encoding, a surrogate, a truncated sequence, a scalar outside Unicode, or a start past the end.
fn validatesource
forall C, S where ReadBytes[C, S], Copy[S].
fn validate(&cx: C, bytes: S) -> bool { ... }
Whether all of bytes is UTF-8 that decode reads, scalar after scalar to the end.
fn widthsource
fn width(code: u32) -> usize { ... }
How many bytes the UTF-8 form of code takes; 0 when code is not a Unicode scalar (a surrogate, or past U+10FFFF).
fn encodesource
forall W where Writer[W].
fn encode(out: W, code: u32) -> W { ... }
Writes the UTF-8 form of code to out. A code that is not a scalar (width 0) is written as U+FFFD, the replacement character.