Skip to main content

truncate_middle_bytes

Function truncate_middle_bytes 

Source
pub fn truncate_middle_bytes(content: &str, max_bytes: usize) -> String
Expand description

Truncate to an exact UTF-8 byte budget while preserving both ends.

This differs from truncate_middle, whose budget is measured in Unicode scalar values. Protocol envelopes and tool-result limits are byte budgets, so multi-byte text must be cut on a character boundary without exceeding max_bytes after the marker is included.