builtin/rune: document length_in_bytes method

pull/13826/head
Nick Treleaven 2022-03-25 15:36:26 +00:00
parent 0ca87ad09f
commit 08719622be
1 changed files with 2 additions and 0 deletions

View File

@ -61,6 +61,8 @@ pub fn (c rune) bytes() []byte {
return res
}
// length_in_bytes returns the number of bytes needed to store the code point.
// Returns -1 if the data is not a valid code point.
pub fn (c rune) length_in_bytes() int {
code := u32(c)
if code <= 0x7F {