1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 00:42:45 +01:00

Codechange: StringFilter now uses std::string_view entirely (#13869)

This commit is contained in:
frosch
2025-03-22 20:35:31 +01:00
committed by GitHub
parent 667d013726
commit d4ae0f70da
4 changed files with 19 additions and 6 deletions

View File

@@ -368,6 +368,20 @@ bool StrEqualsIgnoreCase(const std::string_view str1, const std::string_view str
return StrCompareIgnoreCase(str1, str2) == 0;
}
/**
* Checks if a string is contained in another string, while ignoring the case of the characters.
*
* @param str The string to search in.
* @param value The string to search for.
* @return True if a match was found.
*/
bool StrContainsIgnoreCase(const std::string_view str, const std::string_view value)
{
CaseInsensitiveStringView ci_str{ str.data(), str.size() };
CaseInsensitiveStringView ci_value{ value.data(), value.size() };
return ci_str.find(ci_value) != ci_str.npos;
}
/**
* Get the length of an UTF-8 encoded string in number of characters
* and thus not the number of bytes that the encoded string contains.