API Reference › Unicode › Unicode.char_at
method

Unicode.char_at

Unicode.char_at(s, i) -> int

Returns the code point at code-point index i as an integer (a Unicode scalar value), or -1 when i is out of range. Indexing is by code point, not byte, so it never lands in the middle of a multibyte character.

Parameters

sthe UTF-8 string
ithe code-point index (0-based)

Example

program CharAt {
  entry {
    print(Unicode.char_at("hello", 0))   # 104 = 'h'
  }
}
← All symbols