utf8.substr
Available inall subroutines.
Returns a substring of the UTF-8 string s
, starting from the Unicode code
point offset
, of Unicode code point length
. The substring is a copy of the
original bytes.
For example, substr("%u{3b1}%u{3b2}%u{3b3}", 1, 1)
is "β"
.
See substr
for the exact semantics of the
offset
and length
.
If the input string is not valid UTF-8, an unset value is returned.
IMPORTANT: UTF-8 allows you to combine characters, which are separate code points. While utf8.substr
correctly honors the Unicode code point boundaries, however, requesting a substring of several of them may not necessarily represent a meaningful grapheme cluster.