get the number of bytes of a code point based on its first byte display: private
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=c_int8_t), | intent(in) | :: | byte |
pure function codepoint_num_bytes(byte) result(n)
integer(kind=c_int8_t), intent(in) :: byte
integer :: n
n = NUM_BYTES_UTF8(iand(int(byte, 4), int(z'000000FF', 4)))
if (n == 0) n = 1
end function codepoint_num_bytes