From f23fa7b0fe287ef7b1b900fee6663f57b8d9c51f Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 28 Mar 2019 14:44:58 +0200 Subject: [PATCH] Added: const char* version of toLower() --HG-- branch : develop --- code/nel/include/nel/misc/common.h | 1 + code/nel/src/misc/common.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index eb70fce9e..d5d59b130 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -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 diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 48e6e9845..72f29eb82 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -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) {