Converts character sequence to title case (Specification)
Version: experimental
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | string |
pure function to_title(string) result(title_string) character(len=*), intent(in) :: string character(len=len(string)) :: title_string integer :: i logical :: capitalize_switch capitalize_switch = .true. do i = 1, len(string) if (is_alphanum(string(i:i))) then if (capitalize_switch) then title_string(i:i) = char_to_upper(string(i:i)) capitalize_switch = .false. else title_string(i:i) = char_to_lower(string(i:i)) end if else title_string(i:i) = string(i:i) capitalize_switch = .true. end if end do end function to_title