AK+LibTextCodec: Stop using Utf16View endianness override

This is preparation for removing the endianness override, since it was
only used by a single client: LibTextCodec.

While here, add helpers and make use of simdutf for fast conversion.
This commit is contained in:
Andreas Kling 2025-04-15 17:49:09 +02:00 committed by Andreas Kling
commit 0e9480b944
Notes: github-actions[bot] 2025-04-16 08:06:08 +00:00
7 changed files with 56 additions and 53 deletions

View file

@ -17,12 +17,12 @@ namespace TextCodec {
class Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) = 0;
virtual bool validate(StringView);
virtual ErrorOr<String> to_utf8(StringView);
protected:
virtual ~Decoder() = default;
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) = 0;
};
class UTF8Decoder final : public Decoder {
@ -34,16 +34,20 @@ public:
class UTF16BEDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
virtual bool validate(StringView) override;
virtual ErrorOr<String> to_utf8(StringView) override;
private:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)>) override { VERIFY_NOT_REACHED(); }
};
class UTF16LEDecoder final : public Decoder {
public:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
virtual bool validate(StringView) override;
virtual ErrorOr<String> to_utf8(StringView) override;
private:
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)>) override { VERIFY_NOT_REACHED(); }
};
template<Integral ArrayType = u32>