From 6b497b87105dceb6349915732d1fa70fdaf07323 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 28 Jan 2023 21:07:48 +0100 Subject: [PATCH] AK: Add two helpers to DeprecatedStringCodePointIterator --- AK/Utf8View.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AK/Utf8View.h b/AK/Utf8View.h index f8c05539231..624eab7cbd0 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -141,6 +141,18 @@ public: return value; } + [[nodiscard]] Optional 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())