to_title Function

public pure function to_title(string) result(title_string)

Convert character variable to title case (Specification)

Version: experimental

Arguments

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

Return Value character(len=len(string))


Calls

proc~~to_title~~CallsGraph proc~to_title to_title proc~is_alphanum is_alphanum proc~to_title->proc~is_alphanum

Contents

Source Code


Variables

TypeVisibility AttributesNameInitial
integer, public :: i
integer, public :: n

Source Code

    pure function to_title(string) result(title_string)
        character(len=*), intent(in) :: string
        character(len=len(string)) :: title_string
        integer :: i, n

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

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

    end function to_title