Skip to main content

Module truncate

Module truncate 

Source
Expand description

Truncation utilities for safe string handling.

Provides functions to truncate strings while respecting UTF-8 boundaries.

Functions§

find_boundary
Find a safe UTF-8 boundary position. Returns the largest position <= max that is a valid char boundary.
truncate_bytes
Truncate string to max bytes, respecting UTF-8 boundaries. Does not add any suffix.
truncate_chars
Truncate string to max characters (not bytes). Useful for display purposes where visual length matters.
truncate_string_in_place
Truncate string and modify in place (for String types).
truncate_with_suffix
Truncate string to max bytes with “…” suffix. Respects UTF-8 boundaries.