2020-05-03 22:41:34 +02:00
|
|
|
/*
|
2021-02-16 17:31:22 +01:00
|
|
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
2020-05-03 22:41:34 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-03 22:41:34 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
|
|
|
|
|
|
|
namespace TextCodec {
|
|
|
|
|
|
|
|
class Decoder {
|
|
|
|
public:
|
|
|
|
virtual String to_utf8(const StringView&) = 0;
|
2021-04-15 10:43:29 -07:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~Decoder() = default;
|
2020-05-03 22:41:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class UTF8Decoder final : public Decoder {
|
|
|
|
public:
|
|
|
|
virtual String to_utf8(const StringView&) override;
|
|
|
|
};
|
|
|
|
|
2021-02-16 17:31:22 +01:00
|
|
|
class UTF16BEDecoder final : public Decoder {
|
|
|
|
public:
|
|
|
|
virtual String to_utf8(const StringView&) override;
|
|
|
|
};
|
|
|
|
|
2020-05-03 22:41:34 +02:00
|
|
|
class Latin1Decoder final : public Decoder {
|
|
|
|
public:
|
|
|
|
virtual String to_utf8(const StringView&) override;
|
|
|
|
};
|
|
|
|
|
2020-12-27 22:44:38 +01:00
|
|
|
class Latin2Decoder final : public Decoder {
|
|
|
|
public:
|
|
|
|
virtual String to_utf8(const StringView&) override;
|
|
|
|
};
|
|
|
|
|
2021-04-17 18:15:32 +03:00
|
|
|
class HebrewDecoder final : public Decoder {
|
|
|
|
public:
|
|
|
|
virtual String to_utf8(const StringView&) override;
|
|
|
|
};
|
|
|
|
|
2021-05-01 18:18:26 +03:00
|
|
|
class CyrillicDecoder final : public Decoder {
|
|
|
|
public:
|
|
|
|
virtual String to_utf8(const StringView&) override;
|
|
|
|
};
|
|
|
|
|
2021-06-15 16:07:56 +03:00
|
|
|
class Latin9Decoder final : public Decoder {
|
|
|
|
public:
|
|
|
|
virtual String to_utf8(const StringView&) override;
|
|
|
|
};
|
|
|
|
|
2020-05-03 22:41:34 +02:00
|
|
|
Decoder* decoder_for(const String& encoding);
|
2021-05-11 15:52:25 +02:00
|
|
|
Optional<String> get_standardized_encoding(const String& encoding);
|
2020-11-13 11:14:02 +00:00
|
|
|
bool is_standardized_encoding(const String& encoding);
|
2020-05-03 22:41:34 +02:00
|
|
|
|
|
|
|
}
|