API Reference › Unicode › Unicode.byte_len
method

Unicode.byte_len

Unicode.byte_len(s) -> int

The number of bytes the string occupies — its storage size. This is what raw byte APIs and buffers care about, and it is greater than len whenever the text contains non-ASCII code points (each of which encodes to 2–4 bytes).

Parameters

sthe UTF-8 string

Example

program ByteLen {
  entry {
    print(Unicode.byte_len("hello"))   # 5 (all ASCII)
  }
}
← All symbols