summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTextCodec/Decoder.h
blob: 871ef35d9a2ae491707c291b8e3ff02deb014d12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Forward.h>

namespace TextCodec {

class Decoder {
public:
    virtual String to_utf8(const StringView&) = 0;

protected:
    virtual ~Decoder() = default;
};

class UTF8Decoder final : public Decoder {
public:
    virtual String to_utf8(const StringView&) override;
};

class UTF16BEDecoder final : public Decoder {
public:
    virtual String to_utf8(const StringView&) override;
};

class Latin1Decoder final : public Decoder {
public:
    virtual String to_utf8(const StringView&) override;
};

class Latin2Decoder final : public Decoder {
public:
    virtual String to_utf8(const StringView&) override;
};

class HebrewDecoder final : public Decoder {
public:
    virtual String to_utf8(const StringView&) override;
};

class CyrillicDecoder final : public Decoder {
public:
    virtual String to_utf8(const StringView&) override;
};

class Latin9Decoder final : public Decoder {
public:
    virtual String to_utf8(const StringView&) override;
};

class TurkishDecoder final : public Decoder {
public:
    virtual String to_utf8(const StringView&) override;
};

Decoder* decoder_for(const String& encoding);
Optional<String> get_standardized_encoding(const String& encoding);
bool is_standardized_encoding(const String& encoding);

}