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:
parent
c1958437f9
commit
08a8d67a5b
Notes:
github-actions[bot]
2024-08-08 16:51:03 +00:00
Author: https://github.com/BenJilks
Commit: 08a8d67a5b
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 ✅
3 changed files with 119 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue