oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.49k stars 2.71k forks source link

GBK encoding is not supported by TextDecoder #10696

Open Bassintag opened 5 months ago

Bassintag commented 5 months ago

What version of Bun is running?

1.1.6+e58d67b46

What platform is your computer?

Linux 6.5.0-28-generic x86_64 x86_64

What steps can reproduce the bug?

Create a bun script and try to instantiate a new TextDecoder

// This will fail with either gbk or GBK
const decoder = new TextDecoder('gbk');

What is the expected behavior?

It should accept the gbk encoding as specified on the MDN web docs: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder

What do you see instead?

TypeError: Unsupported encoding label "GBK"
 code: "ERR_INVALID_ARG_TYPE"

Additional information

More about the GBK format: https://en.wikipedia.org/wiki/GBK_(character_encoding) It is still used over utf-8 by some chinese websites, not supporting it leads to wrongly decoded characters when using fetch for example

dinfer commented 3 months ago

same problem here. I'm using https://www.npmjs.com/package/text-decoding to decode GBK, it works fine