to_sentence Function

public elemental function to_sentence(string) result(sentence_string)

Converts character sequence to sentence case (Specification)

Version: experimental

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: string

Return Value character(len=len)


Source Code

    elemental function to_sentence(string) result(sentence_string)
        character(len=*), intent(in) :: string
        character(len=len(string)) :: sentence_string
        integer :: i, n

        n = len(string)
        do i = 1, len(string)
            if (is_alphanum(string(i:i))) then
                sentence_string(i:i) = char_to_upper(string(i:i))
                n = i
                exit
            else
                sentence_string(i:i) = string(i:i)
            end if
        end do

        do i = n + 1, len(string)
            sentence_string(i:i) = char_to_lower(string(i:i))
        end do

    end function to_sentence