Skip to main content

truncate_utf8

Function truncate_utf8 

Source
pub fn truncate_utf8(input: &str, max_bytes: usize) -> (String, bool)
Expand description

Truncate a UTF-8 string to at most max_bytes, returning the (possibly truncated) string and a flag indicating whether truncation occurred.

Truncation always happens on a char boundary to keep the result valid UTF-8.