Skip to main content

Module text

Module text 

Source
Expand description

Text length and UTF-8-safe truncation helpers.

Aster services often need conservative limits for display text, file names, status messages, or external-system error snippets. This module keeps byte-based truncation UTF-8-safe and provides a small character-count helper for product validation rules that are expressed in Unicode scalar values instead of bytes.

Functionsยง

char_count
Returns the number of Unicode scalar values in a string.
truncate_utf8_to_max_bytes
Truncates a string to at most max_bytes bytes without splitting a UTF-8 code point.