handle latin1 in Bun__encoding__toString. (#3739)

Close: #3738
This commit is contained in:
Ai Hoshino
2023-07-22 13:01:26 +08:00
committed by GitHub
parent 2323f5d08d
commit 1ecd9f8a18
2 changed files with 11 additions and 0 deletions

View File

@@ -250,3 +250,13 @@ it("invalid utf-8 input, pr #3562", () => {
output += decoder.end();
expect(output).toStrictEqual("\uFFFD\uFFFD");
});
it("decoding latin1, issue #3738", () => {
const decoder = new RealStringDecoder("latin1");
let output = "";
output += decoder.write(Buffer.from("DD", "hex"));
output += decoder.write(Buffer.from("59", "hex"));
output += decoder.write(Buffer.from("DE", "hex"));
output += decoder.end();
expect(output).toStrictEqual("ÝYÞ");
});