utf8_len Function

public pure function utf8_len(utf8) result(l)

return the number of UTF-8 code points

Arguments

TypeIntentOptionalAttributesName
class(utf8_string), intent(in) :: utf8

Return Value integer


Contents

Source Code


Source Code

    pure function utf8_len(utf8) result(l)
        class(utf8_string), intent(in) :: utf8
        integer :: l
        integer :: i

        l = 0; i = 1
        do
            if (i > len(utf8%str)) exit
            i = i + codepoint_num_bytes(cast_byte(utf8%str(i:i)))
            l = l + 1
        end do

    end function utf8_len