mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: Add Utf8View::length_in_codepoints()
This commit is contained in:
@@ -132,6 +132,16 @@ bool Utf8View::validate() const
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t Utf8View::length_in_codepoints() const
|
||||
{
|
||||
size_t length = 0;
|
||||
for (auto codepoint : *this) {
|
||||
(void)codepoint;
|
||||
++length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
Utf8CodepointIterator::Utf8CodepointIterator(const unsigned char* ptr, int length)
|
||||
: m_ptr(ptr)
|
||||
, m_length(length)
|
||||
|
||||
@@ -72,6 +72,8 @@ public:
|
||||
|
||||
bool validate() const;
|
||||
|
||||
size_t length_in_codepoints() const;
|
||||
|
||||
private:
|
||||
const unsigned char* begin_ptr() const;
|
||||
const unsigned char* end_ptr() const;
|
||||
|
||||
Reference in New Issue
Block a user