Merge pull request #217 from diamante0018/string-funcs

[String] Port changes from S1x
This commit is contained in:
Dss0 2022-04-10 13:13:00 +02:00 committed by GitHub
commit 689ea11a20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -23,16 +23,24 @@ namespace Utils
return result;
}
std::string ToLower(std::string input)
std::string ToLower(std::string text)
{
std::transform(input.begin(), input.end(), input.begin(), ::tolower);
return input;
std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input)
{
return static_cast<char>(std::tolower(input));
});
return text;
}
std::string ToUpper(std::string input)
std::string ToUpper(std::string text)
{
std::transform(input.begin(), input.end(), input.begin(), ::toupper);
return input;
std::transform(text.begin(), text.end(), text.begin(), [](const unsigned char input)
{
return static_cast<char>(std::toupper(input));
});
return text;
}
std::string DumpHex(const std::string& data, const std::string& separator)

View File

@ -75,8 +75,8 @@ namespace Utils
const char *VA(const char *fmt, ...);
int IsSpace(int c);
std::string ToLower(std::string input);
std::string ToUpper(std::string input);
std::string ToLower(std::string text);
std::string ToUpper(std::string text);
bool EndsWith(const std::string& haystack, const std::string& needle);
std::vector<std::string> Split(const std::string& str, const char delim);
void Replace(std::string& string, const std::string& find, const std::string& replace);