mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
LibJS: Fix UTF-16 corruption in String.prototype.replace()
We were mistakenly trying to append UTF-16 code units to a StringBuilder via the append(char) API. This patch fixes that by accumulating the result in a Vector<u16> instead. This'll be a bit worse for performance, since we're now doing additional UTF-16 string conversions, but we're going for correctness at this stage and can worry about performance later.
This commit is contained in:
parent
c279fd1097
commit
f7a252ae85
2 changed files with 11 additions and 9 deletions
|
@ -245,4 +245,6 @@ test("UTF-16", () => {
|
|||
expect("😀".replace(/\ud83d/u, "")).toBe("😀");
|
||||
expect("😀".replace(/\ude00/u, "")).toBe("😀");
|
||||
expect("😀".replace(/\ud83d\ude00/u, "")).toBe("");
|
||||
|
||||
expect("".replace("", "😀")).toBe("😀");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue