API Reference › Unicode › Unicode.grapheme_len
method

Unicode.grapheme_len

Unicode.grapheme_len(s) -> int

Counts grapheme clusters — what a reader perceives as one character — which is what you want for cursor movement and visual width. A base letter plus a combining accent, a ZWJ emoji sequence (like a family emoji), and a two–regional-indicator flag each count as one, even though they span several code points. This v1 approximates UAX#29 over those common cases; full segmentation is a follow-up.

Parameters

sthe UTF-8 string

Example

program GraphemeLen {
  entry {
    print(Unicode.grapheme_len("hello"))   # 5 (plain ASCII)
  }
}
← All symbols