Skip to main content

Module utils

Module utils 

Source
Expand description

Shared utility functions for safe string manipulation.

All functions are UTF-8-safe — they never split multi-byte characters, and the newline variant stops at line boundaries for log-preview use cases.

Functions§

truncate_utf8
Truncate s to at most max bytes, landing on a valid UTF-8 character boundary.
truncate_utf8_line
Like truncate_utf8 but also stops at the first newline if it appears before max. Useful for log previews where long multi-line output should show only the first line.