mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
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:
@@ -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;
|
||||
|
||||
@@ -115,6 +115,7 @@ public:
|
||||
bool is_null() const { return m_string.is_null(); }
|
||||
bool starts_with(Utf8View const&) const;
|
||||
bool contains(u32) const;
|
||||
bool contains_any_of(ReadonlySpan<u32>) const;
|
||||
|
||||
Utf8View trim(Utf8View const& characters, TrimMode mode = TrimMode::Both) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user