mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00: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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user