mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
AK: Replace converting to and from UTF-16 with simdutf
The one behavior difference is that we will now actually fail on invalid code units with Utf16View::to_utf8(AllowInvalidCodeUnits::No). It was arguably a bug that this wasn't already the case.
This commit is contained in:
parent
32ffe9bbfc
commit
0c14a9417a
Notes:
sideshowbarker
2024-07-18 23:45:58 +09:00
Author: https://github.com/trflynn89
Commit: 0c14a9417a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/674
Reviewed-by: https://github.com/ADKaster
4 changed files with 81 additions and 23 deletions
|
@ -63,7 +63,7 @@ TEST_CASE(encode_utf8)
|
|||
auto encoded = Array { (u16)0xd83d };
|
||||
Utf16View view { encoded };
|
||||
EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes)), "\xed\xa0\xbd"sv);
|
||||
EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No)), "\ufffd"sv);
|
||||
EXPECT(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No).is_error());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ TEST_CASE(substring_view)
|
|||
|
||||
EXPECT(view.length_in_code_units() == 1);
|
||||
EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes)), "\xed\xa0\xbd"sv);
|
||||
EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No)), "\ufffd"sv);
|
||||
EXPECT(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No).is_error());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue