Number of characters (code points) in UTF-8 text: bytes that are not continuation bytes.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | text |
UTF-8 bytes |
pure integer function utf8_width(text) result(w) !! Number of characters (code points) in UTF-8 `text`: bytes that are not continuation bytes. character(len=*), intent(in) :: text !! UTF-8 bytes integer :: k, c w = 0 do k = 1, len(text) c = iand(ichar(text(k:k)), 255) if (c < 128 .or. c >= 192) w = w + 1 end do end function utf8_width