mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibTextCodec: Use generated lookup tables for all single byte decoders
This commit is contained in:
parent
6b2c459901
commit
0ab4722cee
Notes:
sideshowbarker
2024-07-17 02:29:45 +09:00
Author: https://github.com/skyrising Commit: https://github.com/LadybirdBrowser/ladybird/commit/0ab4722cee Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/32 Reviewed-by: https://github.com/jamierocks
3 changed files with 79 additions and 440 deletions
|
@ -19,6 +19,7 @@ struct LookupTable {
|
||||||
u32 first_pointer;
|
u32 first_pointer;
|
||||||
u32 max_code_point;
|
u32 max_code_point;
|
||||||
Vector<u32> code_points;
|
Vector<u32> code_points;
|
||||||
|
bool generate_accessor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LookupTables {
|
struct LookupTables {
|
||||||
|
@ -26,7 +27,12 @@ struct LookupTables {
|
||||||
OrderedHashMap<StringView, LookupTable> indexes;
|
OrderedHashMap<StringView, LookupTable> indexes;
|
||||||
};
|
};
|
||||||
|
|
||||||
LookupTable prepare_table(JsonArray const& data)
|
enum class GenerateAccessor {
|
||||||
|
No,
|
||||||
|
Yes,
|
||||||
|
};
|
||||||
|
|
||||||
|
LookupTable prepare_table(JsonArray const& data, GenerateAccessor generate_accessor = GenerateAccessor::No)
|
||||||
{
|
{
|
||||||
Vector<u32> code_points;
|
Vector<u32> code_points;
|
||||||
code_points.ensure_capacity(data.size());
|
code_points.ensure_capacity(data.size());
|
||||||
|
@ -45,9 +51,13 @@ LookupTable prepare_table(JsonArray const& data)
|
||||||
max = AK::max(max, code_points.last());
|
max = AK::max(max, code_points.last());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (code_points.last() == 0xfffd)
|
if (generate_accessor == GenerateAccessor::Yes) {
|
||||||
code_points.take_last();
|
while (code_points.last() == 0xfffd)
|
||||||
return { first_pointer, max, move(code_points) };
|
code_points.take_last();
|
||||||
|
} else {
|
||||||
|
VERIFY(first_pointer == 0);
|
||||||
|
}
|
||||||
|
return { first_pointer, max, move(code_points), generate_accessor == GenerateAccessor::Yes };
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_table(SourceGenerator generator, StringView name, LookupTable& table)
|
void generate_table(SourceGenerator generator, StringView name, LookupTable& table)
|
||||||
|
@ -68,7 +78,8 @@ void generate_table(SourceGenerator generator, StringView name, LookupTable& tab
|
||||||
generator.append(i % 16 == 15 ? ",\n "sv : ", "sv);
|
generator.append(i % 16 == 15 ? ",\n "sv : ", "sv);
|
||||||
}
|
}
|
||||||
generator.appendln("\n};");
|
generator.appendln("\n};");
|
||||||
generator.appendln("Optional<u32> index_@name@_code_point(u32 pointer);");
|
if (table.generate_accessor)
|
||||||
|
generator.appendln("Optional<u32> index_@name@_code_point(u32 pointer);");
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> generate_header_file(LookupTables& tables, Core::File& file)
|
ErrorOr<void> generate_header_file(LookupTables& tables, Core::File& file)
|
||||||
|
@ -110,7 +121,7 @@ static constexpr Array<Gb18030RangeEntry, @gb18030_ranges_size@> s_gb18030_range
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate_table_implementation(SourceGenerator generator, StringView name, LookupTable& table)
|
void generate_table_accessor(SourceGenerator generator, StringView name, LookupTable& table)
|
||||||
{
|
{
|
||||||
generator.set("name", name);
|
generator.set("name", name);
|
||||||
generator.set("first_pointer", MUST(String::number(table.first_pointer)));
|
generator.set("first_pointer", MUST(String::number(table.first_pointer)));
|
||||||
|
@ -154,8 +165,9 @@ ErrorOr<void> generate_implementation_file(LookupTables& tables, Core::File& fil
|
||||||
namespace TextCodec {
|
namespace TextCodec {
|
||||||
)~~~");
|
)~~~");
|
||||||
|
|
||||||
for (auto e : tables.indexes) {
|
for (auto& [key, table] : tables.indexes) {
|
||||||
generate_table_implementation(generator.fork(), e.key, e.value);
|
if (table.generate_accessor)
|
||||||
|
generate_table_accessor(generator.fork(), key, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
generator.appendln("\n}");
|
generator.appendln("\n}");
|
||||||
|
@ -180,7 +192,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto json_data = TRY(json_file->read_until_eof());
|
auto json_data = TRY(json_file->read_until_eof());
|
||||||
auto data = TRY(JsonValue::from_string(json_data)).as_object();
|
auto data = TRY(JsonValue::from_string(json_data)).as_object();
|
||||||
|
|
||||||
auto gb18030_table = prepare_table(data.get("gb18030"sv)->as_array());
|
auto gb18030_table = prepare_table(data.get("gb18030"sv)->as_array(), GenerateAccessor::Yes);
|
||||||
|
|
||||||
// FIXME: Encoding specification is not updated to GB-18030-2022 yet (https://github.com/whatwg/encoding/issues/312)
|
// FIXME: Encoding specification is not updated to GB-18030-2022 yet (https://github.com/whatwg/encoding/issues/312)
|
||||||
// NOTE: See https://commits.webkit.org/264918@main
|
// NOTE: See https://commits.webkit.org/264918@main
|
||||||
|
@ -207,11 +219,37 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
.gb18030_ranges = data.get("gb18030-ranges"sv)->as_array(),
|
.gb18030_ranges = data.get("gb18030-ranges"sv)->as_array(),
|
||||||
.indexes = {
|
.indexes = {
|
||||||
{ "gb18030"sv, move(gb18030_table) },
|
{ "gb18030"sv, move(gb18030_table) },
|
||||||
{ "big5"sv, prepare_table(data.get("big5"sv)->as_array()) },
|
{ "big5"sv, prepare_table(data.get("big5"sv)->as_array(), GenerateAccessor::Yes) },
|
||||||
{ "jis0208"sv, prepare_table(data.get("jis0208"sv)->as_array()) },
|
{ "jis0208"sv, prepare_table(data.get("jis0208"sv)->as_array(), GenerateAccessor::Yes) },
|
||||||
{ "jis0212"sv, prepare_table(data.get("jis0212"sv)->as_array()) },
|
{ "jis0212"sv, prepare_table(data.get("jis0212"sv)->as_array(), GenerateAccessor::Yes) },
|
||||||
{ "euc_kr"sv, prepare_table(data.get("euc-kr"sv)->as_array()) },
|
{ "euc_kr"sv, prepare_table(data.get("euc-kr"sv)->as_array(), GenerateAccessor::Yes) },
|
||||||
|
{ "ibm866"sv, prepare_table(data.get("ibm866"sv)->as_array()) },
|
||||||
|
{ "iso_8859_2"sv, prepare_table(data.get("iso-8859-2"sv)->as_array()) },
|
||||||
|
{ "iso_8859_3"sv, prepare_table(data.get("iso-8859-3"sv)->as_array()) },
|
||||||
|
{ "iso_8859_4"sv, prepare_table(data.get("iso-8859-4"sv)->as_array()) },
|
||||||
|
{ "iso_8859_5"sv, prepare_table(data.get("iso-8859-5"sv)->as_array()) },
|
||||||
|
{ "iso_8859_6"sv, prepare_table(data.get("iso-8859-6"sv)->as_array()) },
|
||||||
|
{ "iso_8859_7"sv, prepare_table(data.get("iso-8859-7"sv)->as_array()) },
|
||||||
|
{ "iso_8859_8"sv, prepare_table(data.get("iso-8859-8"sv)->as_array()) },
|
||||||
|
{ "iso_8859_10"sv, prepare_table(data.get("iso-8859-10"sv)->as_array()) },
|
||||||
|
{ "iso_8859_13"sv, prepare_table(data.get("iso-8859-13"sv)->as_array()) },
|
||||||
|
{ "iso_8859_14"sv, prepare_table(data.get("iso-8859-14"sv)->as_array()) },
|
||||||
|
{ "iso_8859_15"sv, prepare_table(data.get("iso-8859-15"sv)->as_array()) },
|
||||||
|
{ "iso_8859_16"sv, prepare_table(data.get("iso-8859-16"sv)->as_array()) },
|
||||||
|
{ "koi8_r"sv, prepare_table(data.get("koi8-r"sv)->as_array()) },
|
||||||
|
{ "koi8_u"sv, prepare_table(data.get("koi8-u"sv)->as_array()) },
|
||||||
|
{ "macintosh"sv, prepare_table(data.get("macintosh"sv)->as_array()) },
|
||||||
|
{ "windows_874"sv, prepare_table(data.get("windows-874"sv)->as_array()) },
|
||||||
|
{ "windows_1250"sv, prepare_table(data.get("windows-1250"sv)->as_array()) },
|
||||||
|
{ "windows_1251"sv, prepare_table(data.get("windows-1251"sv)->as_array()) },
|
||||||
{ "windows_1252"sv, prepare_table(data.get("windows-1252"sv)->as_array()) },
|
{ "windows_1252"sv, prepare_table(data.get("windows-1252"sv)->as_array()) },
|
||||||
|
{ "windows_1253"sv, prepare_table(data.get("windows-1253"sv)->as_array()) },
|
||||||
|
{ "windows_1254"sv, prepare_table(data.get("windows-1254"sv)->as_array()) },
|
||||||
|
{ "windows_1255"sv, prepare_table(data.get("windows-1255"sv)->as_array()) },
|
||||||
|
{ "windows_1256"sv, prepare_table(data.get("windows-1256"sv)->as_array()) },
|
||||||
|
{ "windows_1257"sv, prepare_table(data.get("windows-1257"sv)->as_array()) },
|
||||||
|
{ "windows_1258"sv, prepare_table(data.get("windows-1258"sv)->as_array()) },
|
||||||
|
{ "x_mac_cyrillic"sv, prepare_table(data.get("x-mac-cyrillic"sv)->as_array()) },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,7 @@ Latin1Decoder s_latin1_decoder;
|
||||||
UTF8Decoder s_utf8_decoder;
|
UTF8Decoder s_utf8_decoder;
|
||||||
UTF16BEDecoder s_utf16be_decoder;
|
UTF16BEDecoder s_utf16be_decoder;
|
||||||
UTF16LEDecoder s_utf16le_decoder;
|
UTF16LEDecoder s_utf16le_decoder;
|
||||||
Latin2Decoder s_latin2_decoder;
|
|
||||||
Latin9Decoder s_latin9_decoder;
|
|
||||||
PDFDocEncodingDecoder s_pdf_doc_encoding_decoder;
|
PDFDocEncodingDecoder s_pdf_doc_encoding_decoder;
|
||||||
TurkishDecoder s_turkish_decoder;
|
|
||||||
XUserDefinedDecoder s_x_user_defined_decoder;
|
XUserDefinedDecoder s_x_user_defined_decoder;
|
||||||
GB18030Decoder s_gb18030_decoder;
|
GB18030Decoder s_gb18030_decoder;
|
||||||
Big5Decoder s_big5_decoder;
|
Big5Decoder s_big5_decoder;
|
||||||
|
@ -36,263 +33,35 @@ ShiftJISDecoder s_shift_jis_decoder;
|
||||||
EUCKRDecoder s_euc_kr_decoder;
|
EUCKRDecoder s_euc_kr_decoder;
|
||||||
ReplacementDecoder s_replacement_decoder;
|
ReplacementDecoder s_replacement_decoder;
|
||||||
|
|
||||||
// clang-format off
|
// s_{encoding}_index is generated from https://encoding.spec.whatwg.org/indexes.json
|
||||||
// https://encoding.spec.whatwg.org/index-ibm866.txt
|
// Found separately in https://encoding.spec.whatwg.org/index-{encoding}.txt
|
||||||
SingleByteDecoder s_ibm866_decoder {{
|
SingleByteDecoder s_ibm866_decoder { s_ibm866_index };
|
||||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
SingleByteDecoder s_latin2_decoder { s_iso_8859_2_index };
|
||||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
SingleByteDecoder s_latin3_decoder { s_iso_8859_3_index };
|
||||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
SingleByteDecoder s_latin4_decoder { s_iso_8859_4_index };
|
||||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
SingleByteDecoder s_latin_cyrillic_decoder { s_iso_8859_5_index };
|
||||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
SingleByteDecoder s_latin_arabic_decoder { s_iso_8859_6_index };
|
||||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
SingleByteDecoder s_latin_greek_decoder { s_iso_8859_7_index };
|
||||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
|
SingleByteDecoder s_latin_hebrew_decoder { s_iso_8859_8_index };
|
||||||
0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0,
|
SingleByteDecoder s_latin6_decoder { s_iso_8859_10_index };
|
||||||
}};
|
SingleByteDecoder s_latin7_decoder { s_iso_8859_13_index };
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-3.txt
|
SingleByteDecoder s_latin8_decoder { s_iso_8859_14_index };
|
||||||
SingleByteDecoder s_latin3_decoder {{
|
SingleByteDecoder s_latin9_decoder { s_iso_8859_15_index };
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
SingleByteDecoder s_latin10_decoder { s_iso_8859_16_index };
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
SingleByteDecoder s_centraleurope_decoder { s_windows_1250_index };
|
||||||
0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0xFFFD, 0x0124, 0x00A7, 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0xFFFD, 0x017B,
|
SingleByteDecoder s_cyrillic_decoder { s_windows_1251_index };
|
||||||
0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7, 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0xFFFD, 0x017C,
|
SingleByteDecoder s_hebrew_decoder { s_windows_1255_index };
|
||||||
0x00C0, 0x00C1, 0x00C2, 0xFFFD, 0x00C4, 0x010A, 0x0108, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
SingleByteDecoder s_koi8r_decoder { s_koi8_r_index };
|
||||||
0xFFFD, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7, 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
|
SingleByteDecoder s_koi8u_decoder { s_koi8_u_index };
|
||||||
0x00E0, 0x00E1, 0x00E2, 0xFFFD, 0x00E4, 0x010B, 0x0109, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
SingleByteDecoder s_mac_roman_decoder { s_macintosh_index };
|
||||||
0xFFFD, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7, 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9,
|
SingleByteDecoder s_windows874_decoder { s_windows_874_index };
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-4.txt
|
|
||||||
SingleByteDecoder s_latin4_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7, 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF,
|
|
||||||
0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7, 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B,
|
|
||||||
0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A,
|
|
||||||
0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF,
|
|
||||||
0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B,
|
|
||||||
0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-5.txt
|
|
||||||
SingleByteDecoder s_latin_cyrillic_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F,
|
|
||||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
|
||||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
|
||||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
|
||||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
|
|
||||||
0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-6.txt
|
|
||||||
SingleByteDecoder s_latin_arabic_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0xFFFD, 0xFFFD, 0xFFFD, 0x00A4, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x060C, 0x00AD, 0xFFFD, 0xFFFD,
|
|
||||||
0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x061B, 0xFFFD, 0xFFFD, 0xFFFD, 0x061F,
|
|
||||||
0xFFFD, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
|
|
||||||
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
|
|
||||||
0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F,
|
|
||||||
0x0650, 0x0651, 0x0652, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-7.txt
|
|
||||||
SingleByteDecoder s_latin_greek_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x2018, 0x2019, 0x00A3, 0x20AC, 0x20AF, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x037A, 0x00AB, 0x00AC, 0x00AD, 0xFFFD, 0x2015,
|
|
||||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x0385, 0x0386, 0x00B7, 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
|
|
||||||
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
|
|
||||||
0x03A0, 0x03A1, 0xFFFD, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
|
|
||||||
0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
|
|
||||||
0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0xFFFD,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-8.txt
|
|
||||||
SingleByteDecoder s_latin_hebrew_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0xFFFD, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
|
||||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0xFFFD,
|
|
||||||
0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
|
|
||||||
0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x2017,
|
|
||||||
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
|
|
||||||
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0x200E, 0x200F, 0xFFFD,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-10.txt
|
|
||||||
SingleByteDecoder s_latin6_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7, 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A,
|
|
||||||
0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7, 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2015, 0x016B, 0x014B,
|
|
||||||
0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF,
|
|
||||||
0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168, 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
|
|
||||||
0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF,
|
|
||||||
0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169, 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-13.txt
|
|
||||||
SingleByteDecoder s_latin7_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x201D, 0x00A2, 0x00A3, 0x00A4, 0x201E, 0x00A6, 0x00A7, 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6,
|
|
||||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x201C, 0x00B5, 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
|
|
||||||
0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
|
|
||||||
0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
|
|
||||||
0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
|
|
||||||
0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x2019,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-14.txt
|
|
||||||
SingleByteDecoder s_latin8_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x1E02, 0x1E03, 0x00A3, 0x010A, 0x010B, 0x1E0A, 0x00A7, 0x1E80, 0x00A9, 0x1E82, 0x1E0B, 0x1EF2, 0x00AD, 0x00AE, 0x0178,
|
|
||||||
0x1E1E, 0x1E1F, 0x0120, 0x0121, 0x1E40, 0x1E41, 0x00B6, 0x1E56, 0x1E81, 0x1E57, 0x1E83, 0x1E60, 0x1EF3, 0x1E84, 0x1E85, 0x1E61,
|
|
||||||
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
|
||||||
0x0174, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x1E6A, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x0176, 0x00DF,
|
|
||||||
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
|
||||||
0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-iso-8859-16.txt
|
|
||||||
SingleByteDecoder s_latin10_decoder {{
|
|
||||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x0104, 0x0105, 0x0141, 0x20AC, 0x201E, 0x0160, 0x00A7, 0x0161, 0x00A9, 0x0218, 0x00AB, 0x0179, 0x00AD, 0x017A, 0x017B,
|
|
||||||
0x00B0, 0x00B1, 0x010C, 0x0142, 0x017D, 0x201D, 0x00B6, 0x00B7, 0x017E, 0x010D, 0x0219, 0x00BB, 0x0152, 0x0153, 0x0178, 0x017C,
|
|
||||||
0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0106, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
|
||||||
0x0110, 0x0143, 0x00D2, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x015A, 0x0170, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0118, 0x021A, 0x00DF,
|
|
||||||
0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x0107, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
|
||||||
0x0111, 0x0144, 0x00F2, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x015B, 0x0171, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0119, 0x021B, 0x00FF,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-windows-1250.txt
|
|
||||||
SingleByteDecoder s_centraleurope_decoder {{
|
|
||||||
0x20AC, 0x0081, 0x201A, 0x0083, 0x201E, 0x2026, 0x2020, 0x2021, 0x0088, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
|
|
||||||
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0098, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A,
|
|
||||||
0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B,
|
|
||||||
0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C,
|
|
||||||
0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7, 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
|
|
||||||
0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7, 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
|
|
||||||
0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7, 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
|
|
||||||
0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7, 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-windows-1251.txt
|
|
||||||
SingleByteDecoder s_cyrillic_decoder {{
|
|
||||||
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021, 0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
|
|
||||||
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0098, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
|
|
||||||
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7, 0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
|
|
||||||
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7, 0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
|
|
||||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
|
||||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
|
||||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
|
||||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-windows-1255.txt
|
|
||||||
SingleByteDecoder s_hebrew_decoder {{
|
|
||||||
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x008A, 0x2039, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x009A, 0x203A, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AA, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
|
||||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
|
||||||
0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7, 0x05B8, 0x05B9, 0x05BA, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
|
|
||||||
0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
|
|
||||||
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
|
|
||||||
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0xFFFD, 0xFFFD, 0x200E, 0x200F, 0xFFFD,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-koi8-r.txt
|
|
||||||
SingleByteDecoder s_koi8r_decoder {{
|
|
||||||
0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
|
|
||||||
0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
|
|
||||||
0x2550, 0x2551, 0x2552, 0xD191, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E,
|
|
||||||
0x255F, 0x2560, 0x2561, 0xD081, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9,
|
|
||||||
0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
|
|
||||||
0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
|
|
||||||
0x042E, 0x0410, 0x0441, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
|
|
||||||
0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-koi8-u.txt
|
|
||||||
SingleByteDecoder s_koi8u_decoder {{
|
|
||||||
0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524, 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
|
|
||||||
0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2219, 0x221A, 0x2248, 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
|
|
||||||
0x2550, 0x2551, 0x2552, 0x0451, 0x0454, 0x2554, 0x0456, 0x0457, 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x0491, 0x045E, 0x255E,
|
|
||||||
0x255F, 0x2560, 0x2561, 0x0401, 0x0404, 0x2563, 0x0406, 0x0407, 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x0490, 0x040E, 0x00A9,
|
|
||||||
0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
|
|
||||||
0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
|
|
||||||
0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
|
|
||||||
0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-macintosh.txt
|
|
||||||
SingleByteDecoder s_mac_roman_decoder {{
|
|
||||||
0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, 0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
|
|
||||||
0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3, 0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
|
|
||||||
0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF, 0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
|
|
||||||
0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211, 0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
|
|
||||||
0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB, 0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
|
|
||||||
0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA, 0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02,
|
|
||||||
0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1, 0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
|
|
||||||
0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC, 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-windows-874.txt
|
|
||||||
SingleByteDecoder s_windows874_decoder {{
|
|
||||||
0x20AC, 0x0081, 0x0082, 0x0083, 0x0084, 0x2026, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
|
||||||
0x00A0, 0x0E01, 0x0E02, 0x0E03, 0x0E04, 0x0E05, 0x0E06, 0x0E07, 0x0E08, 0x0E09, 0x0E0A, 0x0E0B, 0x0E0C, 0x0E0D, 0x0E0E, 0x0E0F,
|
|
||||||
0x0E10, 0x0E11, 0x0E12, 0x0E13, 0x0E14, 0x0E15, 0x0E16, 0x0E17, 0x0E18, 0x0E19, 0x0E1A, 0x0E1B, 0x0E1C, 0x0E1D, 0x0E1E, 0x0E1F,
|
|
||||||
0x0E20, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27, 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
|
|
||||||
0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37, 0x0E38, 0x0E39, 0x0E3A, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD, 0x0E3F,
|
|
||||||
0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47, 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
|
|
||||||
0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-windows-1252.txt
|
|
||||||
SingleByteDecoder s_windows1252_decoder { s_windows_1252_index };
|
SingleByteDecoder s_windows1252_decoder { s_windows_1252_index };
|
||||||
// https://encoding.spec.whatwg.org/index-windows-1253.txt
|
SingleByteDecoder s_windows1253_decoder { s_windows_1253_index };
|
||||||
SingleByteDecoder s_windows1253_decoder {{
|
SingleByteDecoder s_turkish_decoder { s_windows_1254_index };
|
||||||
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x0088, 0x2030, 0x008A, 0x2039, 0x008C, 0x008D, 0x008E, 0x008F,
|
SingleByteDecoder s_windows1256_decoder { s_windows_1256_index };
|
||||||
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0098, 0x2122, 0x009A, 0x203A, 0x009C, 0x009D, 0x009E, 0x009F,
|
SingleByteDecoder s_windows1257_decoder { s_windows_1257_index };
|
||||||
0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0xFFFD, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
|
SingleByteDecoder s_windows1258_decoder { s_windows_1258_index };
|
||||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7, 0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
|
SingleByteDecoder s_mac_cyrillic_decoder { s_x_mac_cyrillic_index };
|
||||||
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
|
|
||||||
0x03A0, 0x03A1, 0xFFFD, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
|
|
||||||
0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
|
|
||||||
0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0xFFFD,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-windows-1256.txt
|
|
||||||
SingleByteDecoder s_windows1256_decoder {{
|
|
||||||
0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
|
|
||||||
0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA,
|
|
||||||
0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
|
||||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F,
|
|
||||||
0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
|
|
||||||
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7, 0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643,
|
|
||||||
0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF,
|
|
||||||
0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7, 0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-windows-1257.txt
|
|
||||||
SingleByteDecoder s_windows1257_decoder {{
|
|
||||||
0x20AC, 0x0081, 0x201A, 0x0083, 0x201E, 0x2026, 0x2020, 0x2021, 0x0088, 0x2030, 0x008A, 0x2039, 0x008C, 0x00A8, 0x02C7, 0x00B8,
|
|
||||||
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x0098, 0x2122, 0x009A, 0x203A, 0x009C, 0x00AF, 0x02DB, 0x009F,
|
|
||||||
0x00A0, 0xFFFD, 0x00A2, 0x00A3, 0x00A4, 0xFFFD, 0x00A6, 0x00A7, 0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6,
|
|
||||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
|
|
||||||
0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112, 0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
|
|
||||||
0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7, 0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
|
|
||||||
0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113, 0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
|
|
||||||
0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7, 0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-windows-1258.txt
|
|
||||||
SingleByteDecoder s_windows1258_decoder {{
|
|
||||||
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x02C6, 0x2030, 0x008A, 0x2039, 0x0152, 0x008D, 0x008E, 0x008F,
|
|
||||||
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC, 0x2122, 0x009A, 0x203A, 0x0153, 0x009D, 0x009E, 0x0178,
|
|
||||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
|
||||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
|
||||||
0x00C0, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x0300, 0x00CD, 0x00CE, 0x00CF,
|
|
||||||
0x0110, 0x00D1, 0x0309, 0x00D3, 0x00D4, 0x01A0, 0x00D6, 0x00D7, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x01AF, 0x0303, 0x00DF,
|
|
||||||
0x00E0, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0301, 0x00ED, 0x00EE, 0x00EF,
|
|
||||||
0x0111, 0x00F1, 0x0323, 0x00F3, 0x00F4, 0x01A1, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF,
|
|
||||||
}};
|
|
||||||
// https://encoding.spec.whatwg.org/index-x-mac-cyrillic.txt
|
|
||||||
SingleByteDecoder s_mac_cyrillic_decoder {{
|
|
||||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
|
||||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
|
||||||
0x2020, 0x00B0, 0x0490, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x0406, 0x00AE, 0x00A9, 0x2122, 0x0402, 0x0452, 0x2260, 0x0403, 0x0453,
|
|
||||||
0x221E, 0x00B1, 0x2264, 0x2265, 0x0456, 0x00B5, 0x0491, 0x0408, 0x0404, 0x0454, 0x0407, 0x0457, 0x0409, 0x0459, 0x040A, 0x045A,
|
|
||||||
0x0458, 0x0405, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB, 0x00BB, 0x2026, 0x00A0, 0x040B, 0x045B, 0x040C, 0x045C, 0x0455,
|
|
||||||
0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x201E, 0x040E, 0x045E, 0x040F, 0x045F, 0x2116, 0x0401, 0x0451, 0x044F,
|
|
||||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
|
||||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x20AC,
|
|
||||||
}};
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,127 +531,6 @@ ErrorOr<void> Latin1Decoder::process(StringView input, Function<ErrorOr<void>(u3
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
u32 convert_latin2_to_utf8(u8 in)
|
|
||||||
{
|
|
||||||
switch (in) {
|
|
||||||
|
|
||||||
#define MAP(X, Y) \
|
|
||||||
case X: \
|
|
||||||
return Y
|
|
||||||
|
|
||||||
MAP(0xA1, 0x104);
|
|
||||||
MAP(0xA2, 0x2D8);
|
|
||||||
MAP(0xA3, 0x141);
|
|
||||||
MAP(0xA5, 0x13D);
|
|
||||||
MAP(0xA6, 0x15A);
|
|
||||||
MAP(0xA9, 0x160);
|
|
||||||
MAP(0xAA, 0x15E);
|
|
||||||
MAP(0xAB, 0x164);
|
|
||||||
MAP(0xAC, 0x179);
|
|
||||||
MAP(0xAE, 0x17D);
|
|
||||||
MAP(0xAF, 0x17B);
|
|
||||||
|
|
||||||
MAP(0xB1, 0x105);
|
|
||||||
MAP(0xB2, 0x2DB);
|
|
||||||
MAP(0xB3, 0x142);
|
|
||||||
MAP(0xB5, 0x13E);
|
|
||||||
MAP(0xB6, 0x15B);
|
|
||||||
MAP(0xB7, 0x2C7);
|
|
||||||
MAP(0xB9, 0x161);
|
|
||||||
MAP(0xBA, 0x15F);
|
|
||||||
MAP(0xBB, 0x165);
|
|
||||||
MAP(0xBC, 0x17A);
|
|
||||||
MAP(0xBD, 0x2DD);
|
|
||||||
MAP(0xBE, 0x17E);
|
|
||||||
MAP(0xBF, 0x17C);
|
|
||||||
|
|
||||||
MAP(0xC0, 0x154);
|
|
||||||
MAP(0xC3, 0x102);
|
|
||||||
MAP(0xC5, 0x139);
|
|
||||||
MAP(0xC6, 0x106);
|
|
||||||
MAP(0xC8, 0x10C);
|
|
||||||
MAP(0xCA, 0x118);
|
|
||||||
MAP(0xCC, 0x11A);
|
|
||||||
MAP(0xCF, 0x10E);
|
|
||||||
|
|
||||||
MAP(0xD0, 0x110);
|
|
||||||
MAP(0xD1, 0x143);
|
|
||||||
MAP(0xD2, 0x147);
|
|
||||||
MAP(0xD5, 0x150);
|
|
||||||
MAP(0xD8, 0x158);
|
|
||||||
MAP(0xD9, 0x16E);
|
|
||||||
MAP(0xDB, 0x170);
|
|
||||||
MAP(0xDE, 0x162);
|
|
||||||
|
|
||||||
MAP(0xE0, 0x155);
|
|
||||||
MAP(0xE3, 0x103);
|
|
||||||
MAP(0xE5, 0x13A);
|
|
||||||
MAP(0xE6, 0x107);
|
|
||||||
MAP(0xE8, 0x10D);
|
|
||||||
MAP(0xEA, 0x119);
|
|
||||||
MAP(0xEC, 0x11B);
|
|
||||||
MAP(0xEF, 0x10F);
|
|
||||||
|
|
||||||
MAP(0xF0, 0x111);
|
|
||||||
MAP(0xF1, 0x144);
|
|
||||||
MAP(0xF2, 0x148);
|
|
||||||
MAP(0xF5, 0x151);
|
|
||||||
MAP(0xF8, 0x159);
|
|
||||||
MAP(0xF9, 0x16F);
|
|
||||||
MAP(0xFB, 0x171);
|
|
||||||
MAP(0xFE, 0x163);
|
|
||||||
MAP(0xFF, 0x2D9);
|
|
||||||
#undef MAP
|
|
||||||
|
|
||||||
default:
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Latin2Decoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
|
||||||
{
|
|
||||||
for (auto c : input) {
|
|
||||||
TRY(on_code_point(convert_latin2_to_utf8(c)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> Latin9Decoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
|
||||||
{
|
|
||||||
auto convert_latin9_to_utf8 = [](u8 ch) -> u32 {
|
|
||||||
// Latin9 is the same as the first 256 Unicode code points, except for 8 characters.
|
|
||||||
switch (ch) {
|
|
||||||
case 0xA4:
|
|
||||||
return 0x20AC;
|
|
||||||
case 0xA6:
|
|
||||||
return 0x160;
|
|
||||||
case 0xA8:
|
|
||||||
return 0x161;
|
|
||||||
case 0xB4:
|
|
||||||
return 0x17D;
|
|
||||||
case 0xB8:
|
|
||||||
return 0x17E;
|
|
||||||
case 0xBC:
|
|
||||||
return 0x152;
|
|
||||||
case 0xBD:
|
|
||||||
return 0x153;
|
|
||||||
case 0xBE:
|
|
||||||
return 0x178;
|
|
||||||
default:
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto ch : input) {
|
|
||||||
TRY(on_code_point(convert_latin9_to_utf8(ch)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorOr<void> PDFDocEncodingDecoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
ErrorOr<void> PDFDocEncodingDecoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
||||||
{
|
{
|
||||||
// PDF 1.7 spec, Appendix D.2 "PDFDocEncoding Character Set"
|
// PDF 1.7 spec, Appendix D.2 "PDFDocEncoding Character Set"
|
||||||
|
@ -930,35 +578,6 @@ ErrorOr<void> PDFDocEncodingDecoder::process(StringView input, Function<ErrorOr<
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> TurkishDecoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
|
||||||
{
|
|
||||||
auto convert_turkish_to_utf8 = [](u8 ch) -> u32 {
|
|
||||||
// Turkish (aka ISO-8859-9, Windows-1254) is the same as the first 256 Unicode code points, except for 6 characters.
|
|
||||||
switch (ch) {
|
|
||||||
case 0xD0:
|
|
||||||
return 0x11E;
|
|
||||||
case 0xDD:
|
|
||||||
return 0x130;
|
|
||||||
case 0xDE:
|
|
||||||
return 0x15E;
|
|
||||||
case 0xF0:
|
|
||||||
return 0x11F;
|
|
||||||
case 0xFD:
|
|
||||||
return 0x131;
|
|
||||||
case 0xFE:
|
|
||||||
return 0x15F;
|
|
||||||
default:
|
|
||||||
return ch;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto ch : input) {
|
|
||||||
TRY(on_code_point(convert_turkish_to_utf8(ch)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://encoding.spec.whatwg.org/#x-user-defined-decoder
|
// https://encoding.spec.whatwg.org/#x-user-defined-decoder
|
||||||
ErrorOr<void> XUserDefinedDecoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
ErrorOr<void> XUserDefinedDecoder::process(StringView input, Function<ErrorOr<void>(u32)> on_code_point)
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,30 +66,12 @@ public:
|
||||||
virtual bool validate(StringView) override { return true; }
|
virtual bool validate(StringView) override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Latin2Decoder final : public Decoder {
|
|
||||||
public:
|
|
||||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
|
||||||
virtual bool validate(StringView) override { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class Latin9Decoder final : public Decoder {
|
|
||||||
public:
|
|
||||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
|
||||||
virtual bool validate(StringView) override { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class PDFDocEncodingDecoder final : public Decoder {
|
class PDFDocEncodingDecoder final : public Decoder {
|
||||||
public:
|
public:
|
||||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
||||||
virtual bool validate(StringView) override { return true; }
|
virtual bool validate(StringView) override { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TurkishDecoder final : public Decoder {
|
|
||||||
public:
|
|
||||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
|
||||||
virtual bool validate(StringView) override { return true; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class XUserDefinedDecoder final : public Decoder {
|
class XUserDefinedDecoder final : public Decoder {
|
||||||
public:
|
public:
|
||||||
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
virtual ErrorOr<void> process(StringView, Function<ErrorOr<void>(u32)> on_code_point) override;
|
||||||
|
|
Loading…
Reference in a new issue