LibJS: Implement String.prototype.startsWith with UTF-16 code units

This commit is contained in:
Timothy Flynn 2021-07-19 15:57:05 -04:00 committed by Andreas Kling
commit d2e63a641f
Notes: sideshowbarker 2024-07-18 08:35:27 +09:00
2 changed files with 26 additions and 9 deletions

View file

@ -34,3 +34,11 @@ test("basic functionality", () => {
expect(s.startsWith("", -1)).toBeTrue();
expect(s.startsWith("", 42)).toBeTrue();
});
test("UTF-16", () => {
var s = "😀";
expect(s.startsWith("😀")).toBeTrue();
expect(s.startsWith("\ud83d")).toBeTrue();
expect(s.startsWith("\ude00")).toBeFalse();
expect(s.startsWith("a")).toBeFalse();
});