1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

LibTextCodec: Implement shift_jis encoder

Implements the `shift_jis` encoder, as specified by
https://encoding.spec.whatwg.org/#shift_jis-encoder
This commit is contained in:
BenJilks 2024-08-05 22:38:07 +01:00 committed by Tim Ledbetter
parent c1958437f9
commit 08a8d67a5b
Notes: github-actions[bot] 2024-08-08 16:51:03 +00:00
3 changed files with 119 additions and 0 deletions

View file

@ -44,6 +44,26 @@ TEST_CASE(test_euc_jp_encoder)
EXPECT(processed_bytes[4] == 0xC4);
}
TEST_CASE(test_shift_jis_encoder)
{
TextCodec::ShiftJISEncoder encoder;
// U+A5 Yen Sign
// U+3088 Hiragana Letter Yo
// U+30C4 Katakana Letter Tu
auto test_string = "\U000000A5\U00003088\U000030C4"sv;
Vector<u8> processed_bytes;
MUST(encoder.process(Utf8View(test_string), [&](u8 byte) {
return processed_bytes.try_append(byte);
}));
EXPECT(processed_bytes.size() == 5);
EXPECT(processed_bytes[0] == 0x5C);
EXPECT(processed_bytes[1] == 0x82);
EXPECT(processed_bytes[2] == 0xE6);
EXPECT(processed_bytes[3] == 0x83);
EXPECT(processed_bytes[4] == 0x63);
}
TEST_CASE(test_euc_kr_encoder)
{
TextCodec::EUCKREncoder encoder;