1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:47:35 +00:00

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

This commit is contained in:
Timothy Flynn 2021-07-19 16:53:35 -04:00 committed by Andreas Kling
parent bdbe716547
commit 06208aaa15
3 changed files with 64 additions and 23 deletions

View file

@ -232,3 +232,13 @@ test("override exec with non-function", () => {
re.exec = 3;
expect("test".replace(re, "x")).toBe("x");
});
test("UTF-16", () => {
expect("😀".replace("😀", "")).toBe("");
expect("😀".replace("\ud83d", "")).toBe("\ude00");
expect("😀".replace("\ude00", "")).toBe("\ud83d");
// FIXME: RegExp.prototype [ @@replace ] also needs to support UTF-16.
// expect("😀".replace(/\ud83d/, "")).toBe("\ude00");
// expect("😀".replace(/\ude00/, "")).toBe("\ud83d");
});