Showing the changes to src/core/util_string.cpp (1 of 7 files). Show all
Unified · Split
| @@ -124,6 +124,24 @@ string toupper( const string & str ) · 123 unmodified lines | |||
| 124 | 124 | ||
| 125 | 125 | ||
| 126 | 126 | ||
| 127 | //----------------------------------------------------------------------------- | ||
| 128 | // name: capitalize() | ||
| 129 | // capitalize first character | ||
| 130 | //----------------------------------------------------------------------------- | ||
| 131 | string capitalize( const string & s ) | ||
| 132 | { | ||
| 133 | // copy | ||
| 134 | string retval = s; | ||
| 135 | // if not empty and first character is a lower-case letter | ||
| 136 | if( retval.length() > 0 && retval[0] >= 'a' && retval[0] <= 'z' ) | ||
| 137 | retval[0] -= 32; | ||
| 138 | // done | ||
| 139 | return retval; | ||
| 140 | } | ||
| 141 | |||
| 142 | |||
| 143 | |||
| 144 | |||
| 127 | //----------------------------------------------------------------------------- | 145 | //----------------------------------------------------------------------------- |
| 128 | // name: trim() | 146 | // name: trim() |
| 129 | // desc: ... | 147 | // desc: ... |