mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
d325403cb5
This patch changes get_standardized_encoding to use an Optional<String> return type instead of just returning the null string when unable to match the provided encoding to one of the canonical encoding names. This is part of an effort to move away from using null strings towards explicitly using Optional<String> to indicate that the String may not have a value.
55 lines
1.1 KiB
C++
55 lines
1.1 KiB
C++
/*
|
|
* 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;
|
|
};
|
|
|
|
Decoder* decoder_for(const String& encoding);
|
|
Optional<String> get_standardized_encoding(const String& encoding);
|
|
bool is_standardized_encoding(const String& encoding);
|
|
|
|
}
|