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
: ContinuationByte
* 240..
: TooLongSequence
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)
.
Implementors
impl U8UtfExt for u8