diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txt index 1188c0f9161..72e513c60a9 100644 --- a/AK/CMakeLists.txt +++ b/AK/CMakeLists.txt @@ -33,6 +33,7 @@ set(AK_SOURCES URL.cpp URLParser.cpp Utf16View.cpp + Utf32View.cpp Utf8View.cpp UUID.cpp ) diff --git a/AK/Utf32View.cpp b/AK/Utf32View.cpp new file mode 100644 index 00000000000..de18abb9589 --- /dev/null +++ b/AK/Utf32View.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023, Tim Flynn + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include + +namespace AK { + +ErrorOr Formatter::format(FormatBuilder& builder, Utf32View const& string) +{ + return builder.builder().try_append(string); +} + +} diff --git a/AK/Utf32View.h b/AK/Utf32View.h index 9c116954c4d..2c3c122f99e 100644 --- a/AK/Utf32View.h +++ b/AK/Utf32View.h @@ -8,6 +8,7 @@ #include #include +#include #include namespace AK { @@ -119,6 +120,11 @@ private: size_t m_length { 0 }; }; +template<> +struct Formatter : Formatter { + ErrorOr format(FormatBuilder&, Utf32View const&); +}; + } #if USING_AK_GLOBALLY diff --git a/AK/Utf8View.cpp b/AK/Utf8View.cpp index 5ebfccedfd1..27f44e0b26f 100644 --- a/AK/Utf8View.cpp +++ b/AK/Utf8View.cpp @@ -303,4 +303,9 @@ Optional Utf8CodePointIterator::peek(size_t offset) const return *new_iterator; } +ErrorOr Formatter::format(FormatBuilder& builder, Utf8View const& string) +{ + return Formatter::format(builder, string.as_string()); +} + } diff --git a/AK/Utf8View.h b/AK/Utf8View.h index 624eab7cbd0..e9f7e7635cc 100644 --- a/AK/Utf8View.h +++ b/AK/Utf8View.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include #include @@ -164,6 +165,11 @@ private: Utf8CodePointIterator m_it; }; +template<> +struct Formatter : Formatter { + ErrorOr format(FormatBuilder&, Utf8View const&); +}; + } #if USING_AK_GLOBALLY