Module wtf8

Source

Functionsยง

decode_wtf8_single
Decode one WTF-8 codepoint from a byte array slice. Returns Ok((codepoint, length)) or Err on error.
decode_wtf8_to_scalars
Decode a WTF-8 byte array into a Vec<u16> (UCS-2).
decode_wtf8_to_ucs2
Decode a WTF-8 byte array into a Vec<u16> (UCS-2).
encode_wtf8_from_scalars
More concise encode_wtf8 using ucs2decode/encode_wtf8_single logic. Encodes a slice of Unicode scalar codepoints to WTF-8 bytes. Surrogate pairs are combined and encoded as a single codepoint. Unpaired surrogates are encoded as 3-byte WTF-8 sequences. Values higher than 0x10FFFF are not supported.
encode_wtf8_from_ucs2
WTF-8 encode a UTF-16/UCS-2/JS string (as &u16) into Vec<u8>. Uses ucs2decode to convert to codepoints, then encodes as WTF-8.
encode_wtf8_single
Encode a single Unicode codepoint as WTF-8 byte array. Returns a Vec<u8> containing the WTF-8 encoding of the codepoint. Surrogates and non-scalar values are encoded as WTF-8 allows. Values higher than 0x10FFFF are not supported.
is_unpackable_wtf8
Returns true if the given slice is a valid WTF-8 single codepoint sequence.
read_continuation_byte ๐Ÿ”’