mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
AK: Add starts_with to Utf8View
Unlike String/StringView::starts_with this compares utf8 code points instead of "characters" (bytes), which is important when handling aribtary utf-8 input that could include overlong characters.
This commit is contained in:
parent
3f9ac88c6e
commit
edecf8f6a3
2 changed files with 20 additions and 0 deletions
|
@ -80,6 +80,8 @@ public:
|
|||
Utf8View substring_view(int byte_offset, int byte_length) const;
|
||||
bool is_empty() const { return m_string.is_empty(); }
|
||||
|
||||
bool starts_with(const Utf8View&) const;
|
||||
|
||||
size_t iterator_offset(const Utf8CodepointIterator& it) const
|
||||
{
|
||||
return byte_offset_of(it);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue