API Reference › Unicode › Unicode.len
method

Unicode.len

Unicode.len(s) -> int

Counts the code points in a UTF-8 string — the correct "length" for most text logic, unlike a raw byte count which over-counts anything non-ASCII. Contrast byte_len (storage size) and grapheme_len (user-perceived characters).

Parameters

sthe UTF-8 string

Example

program Len {
  entry {
    print(Unicode.len("hello"))   # 5
  }
}
← All symbols