diff options
author | Andreas Kling <kling@serenityos.org> | 2023-01-28 21:07:48 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-29 23:41:42 +0100 |
commit | 6b497b87105dceb6349915732d1fa70fdaf07323 (patch) | |
tree | dabbf73cd093e6f555a8843ac31eba7b4bfdc4de /AK/Utf8View.h | |
parent | f4c1269d4ce3b9a2a4707a0bca712d154be2dd7e (diff) | |
download | serenity-6b497b87105dceb6349915732d1fa70fdaf07323.zip |
AK: Add two helpers to DeprecatedStringCodePointIterator
Diffstat (limited to 'AK/Utf8View.h')
-rw-r--r-- | AK/Utf8View.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/AK/Utf8View.h b/AK/Utf8View.h index f8c0553923..624eab7cbd 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -141,6 +141,18 @@ public: return value; } + [[nodiscard]] Optional<u32> peek() const + { + if (m_it.done()) + return {}; + return *m_it; + } + + [[nodiscard]] size_t byte_offset() const + { + return Utf8View(m_string).byte_offset_of(m_it); + } + DeprecatedStringCodePointIterator(DeprecatedString string) : m_string(move(string)) , m_it(Utf8View(m_string).begin()) |