oven-sh / bun

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

Support `windows-1251` encoder in `TextDecoder` #6084

Open mrherickz opened 11 months ago

mrherickz commented 11 months ago

What version of Bun is running?

1.0.4+aec0d35f9b90083b93299859822ac67f3389a6d1

What platform is your computer?

Darwin 22.3.0 x86_64 i386

What steps can reproduce the bug?

Try decoding a utf-16be buffer.

new TextDecoder("utf-16be");

What is the expected behavior?

It should be able to decode utf-16be buffers

What do you see instead?

Throws TypeError: Unsupported encoding label "utf-16be"

Additional information

No response

itpcc commented 11 months ago

Same as windows-874:

TypeError: Unsupported encoding label "windows-874"
 code: "ERR_INVALID_ARG_TYPE"

      at ***/src/index.ts:243:21
ReplicantDeckard commented 7 months ago

This also applies to euc-jp:

46 |     const decoder = new TextDecoder('euc-jp');
                         ^
TypeError: Unsupported encoding label "euc-jp"
 code: "ERR_INVALID_ARG_TYPE"

FWIW, according to this MDN page a User Agent must support all the encodings listed on that page to be considered as implementing the Encoding API Spec. Maybe the Bun documentation should be updated to show that TextEncoder and TextDecoder are not fully implemented until all the encodings are supported?

Unfortunately, my code requires that euc-jp be supported, so until Bun fully implements TextDecoder, I have to use Deno instead.

proweb commented 6 months ago

Same with windows-1251

let decoder = new TextDecoder("windows-1251")

goes to

TypeError: Unsupported encoding label "windows-1251"
 code: "ERR_INVALID_ARG_TYPE"
Jarred-Sumner commented 6 months ago

yeah we have only implemented utf16-le and utf8 so far

dylan-conway commented 1 month ago

13214 will add support for utf-16be

mrherickz commented 1 month ago

13214 will add support for utf-16be

Just confirmed via canary build! Thank you so much!

mrherickz commented 1 month ago

Reopening cause windows-1251 encoding is still missing, sorry.