diff options
author | madmaxoft <github@xoft.cz> | 2014-08-04 11:16:19 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-08-04 11:30:20 +0200 |
commit | 1fa210c7f91030ac18fd880fcf131e8104c0b889 (patch) | |
tree | 6d63d6572c053b9474d7c2d6c412d9bb0a516ac5 /src/StringUtils.cpp | |
parent | Anvil: Wolf owner not saved if not present. (diff) | |
download | cuberite-1fa210c7f91030ac18fd880fcf131e8104c0b889.tar cuberite-1fa210c7f91030ac18fd880fcf131e8104c0b889.tar.gz cuberite-1fa210c7f91030ac18fd880fcf131e8104c0b889.tar.bz2 cuberite-1fa210c7f91030ac18fd880fcf131e8104c0b889.tar.lz cuberite-1fa210c7f91030ac18fd880fcf131e8104c0b889.tar.xz cuberite-1fa210c7f91030ac18fd880fcf131e8104c0b889.tar.zst cuberite-1fa210c7f91030ac18fd880fcf131e8104c0b889.zip |
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r-- | src/StringUtils.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 0e30e8ebb..5f88cbf64 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -196,9 +196,9 @@ AString TrimString(const AString & str) -AString & StrToUpper(AString & s) +AString & InPlaceLowercase(AString & s) { - std::transform(s.begin(), s.end(), s.begin(), ::toupper); + std::transform(s.begin(), s.end(), s.begin(), ::tolower); return s; } @@ -206,9 +206,9 @@ AString & StrToUpper(AString & s) -AString & StrToLower(AString & s) +AString & InPlaceUppercase(AString & s) { - std::transform(s.begin(), s.end(), s.begin(), ::tolower); + std::transform(s.begin(), s.end(), s.begin(), ::toupper); return s; } @@ -227,16 +227,25 @@ AString StrToLower(const AString & s) +AString StrToUpper(const AString & s) +{ + AString res(s); + std::transform(res.begin(), res.end(), res.begin(), ::toupper); + return res; +} + + + + + int NoCaseCompare(const AString & s1, const AString & s2) { #ifdef _MSC_VER // MSVC has stricmp that compares case-insensitive: return _stricmp(s1.c_str(), s2.c_str()); #else - // Do it the hard way: - AString s1Copy(s1); - AString s2Copy(s2); - return StrToUpper(s1Copy).compare(StrToUpper(s2Copy)); + // Do it the hard way - convert both strings to lowercase: + return StrToLower(s1).compare(StrToLower(s2)); #endif // else _MSC_VER } |