Skip to main content

truncate_utf8

Function truncate_utf8 

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

Truncates a UTF-8 string to at most max_chars codepoints.

Returns (truncated_string, was_truncated). If max_chars == 0 returns empty string. Unicode-safe: opera sobre codepoints via chars(), nunca quebra no meio.