AK: Add a method to compute UTF-16 length from a UTF-8 string

This commit is contained in:
Timothy Flynn 2024-07-30 06:19:56 -04:00 committed by Tim Flynn
commit 7a17c654d2
Notes: github-actions[bot] 2024-07-31 09:56:36 +00:00
3 changed files with 19 additions and 0 deletions

View file

@ -89,6 +89,14 @@ TEST_CASE(decode_utf16)
EXPECT_EQ(i, expected.size());
}
TEST_CASE(utf16_code_unit_length_from_utf8)
{
EXPECT_EQ(AK::utf16_code_unit_length_from_utf8(""sv), 0uz);
EXPECT_EQ(AK::utf16_code_unit_length_from_utf8("abc"sv), 3uz);
EXPECT_EQ(AK::utf16_code_unit_length_from_utf8("😀"sv), 2uz);
EXPECT_EQ(AK::utf16_code_unit_length_from_utf8("Привет, мир! 😀 γειά σου κόσμος こんにちは世界"sv), 39uz);
}
TEST_CASE(null_view)
{
Utf16View view;