capitalize Function

private elemental function capitalize(self) result(capitalized)

Type Bound

string

Arguments

Type IntentOptional Attributes Name
class(string), intent(in) :: self

Return Value type(string)


Calls

proc~~capitalize~2~~CallsGraph proc~capitalize~2 string%capitalize proc~lower~2 string%lower proc~capitalize~2->proc~lower~2

Called by

proc~~capitalize~2~~CalledByGraph proc~capitalize~2 string%capitalize proc~camelcase~2 string%camelcase proc~camelcase~2->proc~capitalize~2 proc~startcase~2 string%startcase proc~startcase~2->proc~capitalize~2

Source Code

   elemental function capitalize(self) result(capitalized)
   !< Return a string with its first character capitalized and the rest lowercased.
   !<
   !<```fortran
   !< type(string) :: astring
   !< astring = 'say all Hello WorLD!'
   !< print '(L1)', astring%capitalize()//''=='Say all hello world!'
   !<```
   !=> T <<<
   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
   endfunction capitalize