mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 14:18:15 +00:00
Implements the corresponding encoders, selects the appropriate one when encoding URL search params. If an encoder for the given encoding could not be found, fallback to utf-8.
36 lines
765 B
C++
36 lines
765 B
C++
/*
|
|
* Copyright (c) 2024, Ben Jilks <benjyjilks@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Forward.h>
|
|
#include <AK/Function.h>
|
|
|
|
namespace TextCodec {
|
|
|
|
class Encoder {
|
|
public:
|
|
virtual ErrorOr<void> process(Utf8View, Function<ErrorOr<void>(u8)> on_byte) = 0;
|
|
|
|
protected:
|
|
virtual ~Encoder() = default;
|
|
};
|
|
|
|
class UTF8Encoder final : public Encoder {
|
|
public:
|
|
virtual ErrorOr<void> process(Utf8View, Function<ErrorOr<void>(u8)> on_byte) override;
|
|
};
|
|
|
|
class EUCJPEncoder final : public Encoder {
|
|
public:
|
|
virtual ErrorOr<void> process(Utf8View, Function<ErrorOr<void>(u8)> on_byte) override;
|
|
};
|
|
|
|
Optional<Encoder&> encoder_for_exact_name(StringView encoding);
|
|
Optional<Encoder&> encoder_for(StringView label);
|
|
|
|
}
|