Commit Graph
2 Commits
Author SHA1 Message Date
dualfroz 8d093a24a9 fix(strings): count and slice strings by Unicode code point
str_length and str_slice used UTF-8 byte offsets, so any input with
multi-byte characters produced wrong results: str_length("cafe") with
an accented final character returned 5 instead of 4, and str_slice(0,
4, ...) on the same string returned an empty string because the byte
index fell inside the encoding of the last character. This also broke
the higher-level helpers built on top of them (str_find, str_contains,
str_replace).

Count characters with chars().count() and index str_slice by character.
Out-of-range slices still return an empty string, so behavior for ASCII
input is unchanged.
2026-09-04 22:21:11 +02:00
upstream 7df53f6975 Upstream sharkdp/numbat state of the touched files before fa2c3ddcfe 2026-09-02 10:25:31 +02:00