Skip to main content

byte_mouth_pending_tail

Function byte_mouth_pending_tail 

Source
pub fn byte_mouth_pending_tail(s: &str) -> usize
Expand description

Byte offset in s where a trailing INCOMPLETE UTF-8 sequence in the byte spelling begins (s.len() when there is none). The text-run merge in Document::open_text_internal re-decodes only from there: the bytes of one character arrive one token at a time (tex.web §1034: one char node per byte), so a run is complete only once its last continuation byte is on, and everything before the pending lead byte is already decoded (or invalid and final). Invariant relied on: a decoded character in U+00C2..U+00F4 (é, Ã) is never followed by raw continuation bytes without their own lead — well-formed input never produces that shape, so the one preceding character this looks back at is only ever re-merged when it IS the pending lead byte.