AK+LibJS: Do not set UTF-16 code point length to its code unit length

This commit is contained in:
Timothy Flynn 2025-06-25 15:52:01 -04:00 committed by Jelle Raaijmakers
commit efa9737cf7
Notes: github-actions[bot] 2025-06-25 20:22:15 +00:00
3 changed files with 25 additions and 1 deletions

View file

@ -113,6 +113,13 @@ public:
size_t length_in_code_units() const { return m_code_units.size(); }
size_t length_in_code_points() const;
Optional<size_t> length_in_code_points_if_known() const
{
if (m_length_in_code_points == NumericLimits<size_t>::max())
return {};
return m_length_in_code_points;
}
Utf16CodePointIterator begin() const { return { begin_ptr(), m_code_units.size() }; }
Utf16CodePointIterator end() const { return { end_ptr(), 0 }; }