1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:37:34 +00:00

AK: Track byte length, rather than code point length, in Utf8View::trim

Utf8View::trim uses Utf8View::substring_view to return its result, which
requires the input to be a byte offset/length rather than code point
length.
This commit is contained in:
Timothy Flynn 2021-07-16 12:40:46 -04:00 committed by Linus Groh
parent 660a8982e7
commit 87848cdf7d
3 changed files with 49 additions and 8 deletions

View file

@ -56,3 +56,9 @@ test("trimEnd", () => {
expect("\r\nhello friends".trimEnd()).toBe("\r\nhello friends");
expect("\rhello friends\r\n".trimEnd()).toBe("\rhello friends");
});
test("multi-byte code point", () => {
expect("_\u180E".trim()).toBe("_\u180E");
expect("\u180E".trim()).toBe("\u180E");
expect("\u180E_".trim()).toBe("\u180E_");
});