Trait encode_unicode::U8UtfExt [−][src]
pub trait U8UtfExt { fn extra_utf8_bytes(self) -> Result<usize, InvalidUtf8FirstByte>; fn extra_utf8_bytes_unchecked(self) -> usize; }
Methods for working with u8
s as UTF-8 bytes.
Required Methods
fn extra_utf8_bytes(self) -> Result<usize, InvalidUtf8FirstByte>
How many more bytes will you need to complete this codepoint?
Errors
An error is returned if this is not a valid start of an UTF-8 codepoint:
128..192
: ContinuationByte248..
: TooLongSequence Values in 244..248 represent a too high codepoint, but do not cause an error.
fn extra_utf8_bytes_unchecked(self) -> usize
How many more bytes will you need to complete this codepoint?
This function assumes that self is a valid UTF-8 start,
and will return gibberish otherwize.
The formula is self.not().leading_zeros().saturating_sub(1)
.
Implementations on Foreign Types
impl U8UtfExt for u8
[src]
impl U8UtfExt for u8
fn extra_utf8_bytes(self) -> Result<usize, InvalidUtf8FirstByte>
[src]
fn extra_utf8_bytes(self) -> Result<usize, InvalidUtf8FirstByte>
fn extra_utf8_bytes_unchecked(self) -> usize
[src]
fn extra_utf8_bytes_unchecked(self) -> usize