Added: const char* version of toLower()
--HG-- branch : develop
This commit is contained in:
parent
4e7d337297
commit
f23fa7b0fe
2 changed files with 17 additions and 0 deletions
|
@ -222,6 +222,7 @@ inline double isValidDouble (double v)
|
|||
* \param str a string to transform to lower case
|
||||
*/
|
||||
|
||||
std::string toLower ( const char *str );
|
||||
std::string toLower ( const std::string &str );
|
||||
void toLower ( char *str );
|
||||
char toLower ( const char ch ); // convert only one character
|
||||
|
|
|
@ -591,6 +591,22 @@ NLMISC_CATEGORISED_COMMAND(nel,stohr, "Convert a second number into an human rea
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string toLower(const char *str)
|
||||
{
|
||||
if (!str) return "";
|
||||
|
||||
uint len = strlen(str);
|
||||
string res;
|
||||
res.reserve(len);
|
||||
for(uint i = 0; i < len; i++)
|
||||
{
|
||||
if( (str[i] >= 'A') && (str[i] <= 'Z') )
|
||||
res += str[i] - 'A' + 'a';
|
||||
else
|
||||
res += str[i];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string toLower(const std::string &str)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue