Prototype of UTF-8 manipulation in Fortran.
use utf8
implicit none
type(utf8_string) :: s
call construct_utf8_string(s, "Fortran さいこう")
write (*, "('s is a valid utf-8 string: ',g0)") utf8_valid(s)
write (*, "('The number of code points: ',g0)") utf8_len(s)
write (*, "('The 10th code point is ',3A)") "'", utf8_at(s,10), "'"
block !! iterate all code points
type(utf8_string_iterator) :: it
it = s%iterator()
do while (it%has_next())
write (*, "(3A)") "'", it%get_next(), "'"
end do
end block