#![forbid(unsafe_code)] #[derive(Clone, Copy, Debug)] pub enum UTF8ByteType { Single, Introducer(u8), Continuation, Invalid, } pub fn get_utf8_byte_type(b: u8) -> UTF8ByteType { if b & 0x80 == 0 { UTF8ByteType::Single } else if b & 0xC0 == 0x80 { UTF8ByteType::Continuation } else if b & 0xE0 == 0xC0 { UTF8ByteType::Introducer(2) } else if b & 0xF0 == 0xE0 { UTF8ByteType::Introducer(3) } else if b & 0xF8 == 0xF0 { UTF8ByteType::Introducer(4) } else { UTF8ByteType::Invalid } }