rune_len
Table of Contents
Function
rune_len — length of a string in Unicode code points
Synopsis
rune_len(s: string) -> int64
Description
The rune_len function returns the number of Unicode code points in
the argument string s
. Since Zed strings are always encoded as UTF-8,
this length is the same as the number of UTF-8 characters.
Examples
The length in UTF-8 characters of a smiley is 1:
yield rune_len(this)
"hello"
"😎"
Loading...
The length in bytes of a smiley is 4:
yield len(bytes(this))
"hello"
"😎"
Loading...