The binding exposes codepoint counting, Unicode normalization, and full case folding over UTF-8 bytes.
Counts are scalar values, not bytes; normalization covers all four forms (NFC, NFD, NFKC, NFKD).
sz.Utf8Count("你好世界") // 4 codepointssz.Utf8Count("Hello🌍") // 6 — the astral emoji is one scalarsz.Utf8Normalize("é", sz.NFC) // "e" + U+0301 → precomposed "é"sz.Utf8Normalize("fi", sz.NFKC) // ligature "fi" → "fi"
These helpers apply full Unicode case folding.
Each takes a validate flag; when set, inputs are checked and ErrInvalidUTF8 is returned for malformed UTF-8.
Utf8CaseFold returns the case-folded string; folding may expand the output, so "ß" becomes "ss". Utf8CaseInsensitiveFind returns the byte index and matched byte length of the first case-insensitive match, or index == -1 when no match is found; an empty needle returns 0, 0.
For repeated searches with the same needle, Utf8CaseInsensitiveNeedle prepares it once, over its own copy of the bytes.
It is safe for concurrent use, since searches only read it.
It can expand the output, as "ß" → "ss" does, so it allocates up to 3× the input byte size.
Utf8CaseInsensitiveFindUtf8CaseInsensitiveFind finds the first case-insensitive occurrence of needle in haystack using full Unicode case folding and returns byte offsets.
func Utf8Normalize(str string, form NormalForm) string
Malformed bytes pass through unchanged. The destination is sized for the worst-case compatibility decomposition (18x); composing forms never exceed that bound.