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