2024-08-05 12:03:53 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2024, Ben Jilks <benjyjilks@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
|
|
|
|
#include <AK/Function.h>
|
2026-01-16 11:14:26 -03:00
|
|
|
#include <LibTextCodec/Export.h>
|
2025-06-28 16:57:28 -03:00
|
|
|
#include <LibTextCodec/Forward.h>
|
2024-08-05 12:03:53 -03:00
|
|
|
|
|
|
|
|
namespace TextCodec {
|
|
|
|
|
|
2025-06-28 16:57:28 -03:00
|
|
|
class TEXTCODEC_API Encoder {
|
2024-08-05 12:03:53 -03:00
|
|
|
public:
|
2024-08-06 07:06:05 -03:00
|
|
|
virtual ErrorOr<void> process(Utf8View, Function<ErrorOr<void>(u8)> on_byte, Function<ErrorOr<void>(u32)> on_error) = 0;
|
2024-08-05 12:03:53 -03:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual ~Encoder() = default;
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-28 16:57:28 -03:00
|
|
|
TEXTCODEC_API Optional<Encoder&> encoder_for_exact_name(StringView encoding);
|
|
|
|
|
TEXTCODEC_API Optional<Encoder&> encoder_for(StringView label);
|
2024-08-05 12:03:53 -03:00
|
|
|
|
2025-11-24 14:20:51 -03:00
|
|
|
TEXTCODEC_API ByteString isomorphic_encode(StringView);
|
|
|
|
|
|
2024-08-05 12:03:53 -03:00
|
|
|
}
|