capitalize Function

private elemental function capitalize(self) result(capitalized)

Return a string with its first character capitalized and the rest lowercased.

 type(string) :: astring
 astring = 'say all Hello WorLD!'
 print '(L1)', astring%capitalize()//''=='Say all hello world!'

Type Bound

string

Arguments

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

The string.

Return Value type(string)

Upper case string.


Calls

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

Called by

proc~~capitalize~~CalledByGraph proc~capitalize string%capitalize proc~camelcase string%camelcase proc~camelcase->proc~capitalize proc~startcase string%startcase proc~startcase->proc~capitalize program~volatile_doctest~81 volatile_doctest program~volatile_doctest~81->proc~capitalize program~volatile_doctest~18 volatile_doctest program~volatile_doctest~18->proc~camelcase program~volatile_doctest~2 volatile_doctest program~volatile_doctest~2->proc~startcase

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