mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
LibTextCodec: Implement gb18030
and gbk
encoders
Implements the `gb18030` and `gbk` encoders, as specified by https://encoding.spec.whatwg.org/#gb18030-encoder https://encoding.spec.whatwg.org/#gbk-encoder
This commit is contained in:
parent
34c8c559c1
commit
d80575a410
Notes:
github-actions[bot]
2024-08-08 16:51:17 +00:00
Author: https://github.com/BenJilks
Commit: d80575a410
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/975
Reviewed-by: https://github.com/shannonbooth
Reviewed-by: https://github.com/skyrising
Reviewed-by: https://github.com/tcl3 ✅
4 changed files with 152 additions and 1 deletions
|
@ -79,3 +79,22 @@ TEST_CASE(test_big5_encoder)
|
|||
EXPECT(processed_bytes[2] == 0xD2);
|
||||
EXPECT(processed_bytes[3] == 0x71);
|
||||
}
|
||||
|
||||
TEST_CASE(test_gb18030_encoder)
|
||||
{
|
||||
TextCodec::GB18030Encoder encoder;
|
||||
// U+20AC Euro Sign
|
||||
// U+E4C5 Private Use Area
|
||||
auto test_string = "\U000020AC\U0000E4C5"sv;
|
||||
|
||||
Vector<u8> processed_bytes;
|
||||
MUST(encoder.process(Utf8View(test_string), [&](u8 byte) {
|
||||
return processed_bytes.try_append(byte);
|
||||
}));
|
||||
|
||||
EXPECT(processed_bytes.size() == 4);
|
||||
EXPECT(processed_bytes[0] == 0xA2);
|
||||
EXPECT(processed_bytes[1] == 0xE3);
|
||||
EXPECT(processed_bytes[2] == 0xFE);
|
||||
EXPECT(processed_bytes[3] == 0xFE);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue