serenity/Userland/Libraries/LibTextCodec/Decoder.h
Max Wipfli d325403cb5 LibTextCodec: Use Optional<String> for get_standardized_encoding
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.
2021-05-18 21:02:07 +02:00

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);
}