std.utf8.codepoint_size
Show source codeHide source code
fn pub codepoint_size(code: Int) -> Int {
if code < MAX_ONE_B {
1
} else if code < MAX_TWO_B {
2
} else if code < MAX_THREE_B {
3
} else {
4
}
}
fn pub static codepoint_size(code: Int) -> Int
Returns the number of bytes of a code point.
Examples
import std.utf8
utf8.codepoint_size(0x41) # => 1
utf8.codepoint_size(0xDF) # => 2
utf8.codepoint_size(0x1D11) # => 3
utf8.codepoint_size(0x1D11E) # => 4