Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(string), | intent(in) | :: | self | The string. |
Upper case string.
Return a string with its first character capitalized and the rest lowercased.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | c | Character counter. |
elemental function capitalize(self) result(capitalized)
!---------------------------------------------------------------------------------------------------------------------------------
!< Return a string with its first character capitalized and the rest lowercased.
!---------------------------------------------------------------------------------------------------------------------------------
class(string), intent(in) :: self !< The string.
type(string) :: capitalized !< Upper case string.
integer :: c !< Character counter.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(self%raw)) then
capitalized = self%lower()
c = index(LOWER_ALPHABET, capitalized%raw(1:1))
if (c>0) capitalized%raw(1:1) = UPPER_ALPHABET(c:c)
endif
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction capitalize