mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:05:08 +00:00
AK: Add Utf8View::length_in_codepoints()
This commit is contained in:
parent
1469d20e63
commit
6cde7e4d20
2 changed files with 12 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue