AK: Add Utf8View::contains_any_of()

Useful when you need to check for more than one code point, some of
which are multiple bytes. (In which case StringView::contains() will
return wrong results.)
This commit is contained in:
Sam Atkins 2025-01-08 12:56:45 +00:00
commit b16b24c615
Notes: github-actions[bot] 2025-02-04 08:50:31 +00:00
2 changed files with 13 additions and 0 deletions

View file

@ -120,6 +120,18 @@ bool Utf8View::contains(u32 needle) const
return false;
}
bool Utf8View::contains_any_of(ReadonlySpan<u32> needles) const
{
for (u32 const code_point : *this) {
for (auto needle : needles) {
if (code_point == needle)
return true;
}
}
return false;
}
Utf8View Utf8View::trim(Utf8View const& characters, TrimMode mode) const
{
size_t substring_start = 0;