mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-30 14:20:21 +00:00
AK: Implement a method to acquire a UTF-16 iterator's code unit offset
This is the same as Utf8View::iterator_offset().
This commit is contained in:
parent
acf1fe7b05
commit
745f288796
Notes:
github-actions[bot]
2025-07-25 16:18:24 +00:00
Author: https://github.com/trflynn89
Commit: 745f288796
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5604
Reviewed-by: https://github.com/gmta ✅
1 changed files with 17 additions and 0 deletions
|
@ -341,6 +341,23 @@ public:
|
|||
return { m_string.utf16 + length_in_code_units(), 0 };
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr size_t iterator_offset(Utf16CodePointIterator const& it) const
|
||||
{
|
||||
if (has_ascii_storage()) {
|
||||
VERIFY(it.has_ascii_storage());
|
||||
VERIFY(it.m_iterator.ascii >= m_string.ascii);
|
||||
VERIFY(it.m_iterator.ascii <= m_string.ascii);
|
||||
|
||||
return it.m_iterator.ascii - m_string.ascii;
|
||||
}
|
||||
|
||||
VERIFY(!it.has_ascii_storage());
|
||||
VERIFY(it.m_iterator.utf16 >= m_string.utf16);
|
||||
VERIFY(it.m_iterator.utf16 <= m_string.utf16);
|
||||
|
||||
return it.m_iterator.utf16 - m_string.utf16;
|
||||
}
|
||||
|
||||
Utf16String replace(Utf16View const& needle, Utf16View const& replacement, ReplaceMode) const;
|
||||
Utf16String escape_html_entities() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue