String length
var str = "J\x{332}o\x{332}s\x{332}e\x{301}\x{332}"
Byte Length
UTF-8 byte length (default):
say str.bytes.len #=> 14
UTF-16 byte length:
say str.encode('UTF-16').bytes.len #=> 20
Character Length
say str.chars.len #=> 9
Grapheme Length
say str.graphs.len #=> 4
Last updated
Was this helpful?