Skip to main content

snap_to_char_boundary_floor

Function snap_to_char_boundary_floor 

Source
fn snap_to_char_boundary_floor(buf: &[u8], idx: usize) -> usize
Expand description

Snap idx down to the nearest UTF-8 character boundary (or 0). A byte is a UTF-8 char boundary iff it’s either ASCII (< 0x80) or a leading byte (>= 0xC0). Continuation bytes are in 0x80..=0xBF. idx == buf.len() is always a valid boundary (one past the end).