encode_unicode

Trait U8UtfExt

Source
pub trait U8UtfExt {
    // Required methods
    fn extra_utf8_bytes(self) -> Result<usize, InvalidUtf8FirstByte>;
    fn extra_utf8_bytes_unchecked(self) -> usize;
}
Expand description

Methods for working with u8s as UTF-8 bytes.

Required Methods§

Source

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 the byte is not a valid start of an UTF-8 codepoint:

  • 128..192: ContinuationByte
  • 248..: TooLongSequence

Values in 244..248 represent a too high codepoint, but do not cause an error.

Source

fn extra_utf8_bytes_unchecked(self) -> usize

How many more bytes will you need to complete this codepoint?

This function assumes that the byte is a valid UTF-8 start, and might return any value otherwise. (but the function is pure and safe to call with any value).

Implementations on Foreign Types§

Source§

impl U8UtfExt for u8

Implementors§