uce/site/doc/pages/split_utf8.txt

29 lines
955 B
Plaintext

:sig
StringList split_utf8(String str, bool compound_characters = false)
:params
str : string to be split
compound_characters : optional, if true tries to combine compound characters
return value : a list of Unicode characters
:see
>string
:content
Splits `str` into its constituent Unicode code points.
If `compound_characters` is `true`, `split_utf8()` also applies a small amount of grouping so some multi-code-point glyphs stay together. The current rules are:
- combine characters joined by a Zero-Width Joiner (ZWJ)
- combine two Regional Indicator Symbol Letter characters
- append Variation Selectors to the previous character
- otherwise leave characters as separate entries
This is useful when simple byte-wise or ASCII splitting would break Unicode text incorrectly.
Related:
- PHP: `preg_split(//u, ...)`, `mb_*` helpers, or grapheme-aware libraries
- JavaScript / Node.js: `Array.from(str)` or iterator-based Unicode-aware splitting