AK: Provide a length_in_code_units API for UTF-8 strings

This is just to afford API symmetry with UTF-16 strings to help in
templated methods.
This commit is contained in:
Timothy Flynn
2025-08-19 19:40:18 -04:00
committed by Andreas Kling
parent 41eaf0d966
commit b1fe816336
2 changed files with 2 additions and 0 deletions

View File

@@ -74,6 +74,7 @@ public:
[[nodiscard]] ReadonlyBytes bytes() const;
[[nodiscard]] u32 hash() const;
[[nodiscard]] size_t byte_count() const;
[[nodiscard]] ALWAYS_INLINE size_t length_in_code_units() const { return byte_count(); }
[[nodiscard]] bool operator==(StringBase const&) const;

View File

@@ -90,6 +90,7 @@ public:
unsigned char const* bytes() const { return begin_ptr(); }
size_t byte_length() const { return m_string.length(); }
[[nodiscard]] ALWAYS_INLINE size_t length_in_code_units() const { return byte_length(); }
size_t code_point_offset_of(size_t code_unit_offset) const;