Skip to main content

text_trim

Function text_trim 

Source
pub fn text_trim(text: &str, nbytes: usize) -> String
Expand description

Trim text so its UTF-8 encoded size does not exceed nbytes.

Finds the largest valid UTF-8 prefix within nbytes, then strips leading/trailing whitespace from the result. Multi-byte characters that would be split are dropped entirely.