truncateAtWordBreak

Limits str to a length of n UTF-8 code points, cutting off on the last space, if found. If str is not valid UTF-8, str.length is assumed to be the number of code points.

truncateAtWordBreak
(,
size_t n
)
out (result) { if (result.length > n) { assert (g_utf8_validate(result.ptr, result.length, null)); assert (g_utf8_strlen(result.ptr, result.length) <= n); } }

Parameters

str mstring

string to limit the length

n size_t

maximum number of code points in the resulting string

Out: The maximum number of code points in str is n.

Return Value

Type: mstring

The truncated string for method chaining

Meta