Skip to main content

truncate_utf8_to_max_bytes

Function truncate_utf8_to_max_bytes 

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

Truncates a string to at most max_bytes bytes without splitting a UTF-8 code point.

If value is already within the limit it is returned unchanged as an owned string. A zero limit always returns an empty string.