ashtuchkin / iconv-lite

Convert character encodings in pure javascript.
MIT License
3.04k stars 282 forks source link

replace StringDecoder with TextDecoder #316

Open JohnGu9 opened 7 months ago

JohnGu9 commented 7 months ago

Recently I get in trouble with iconv-lite and vite bundler and find out vite silently remove StringDecoder polyfill.

Without StringDecoder, iconv-lite doesn't work any more. So I try to replace StringDecoder with TextDecoder. TextDecoder is a standard es module and be available since node 11.

But the code is not completely move to TextDecoder. hex/base64/binary will depend on Buffer. And if TextDecoder is not available, it will be fallback to StringDecoder.

I don't know whether it's ok to move to TextDecoder. There are some performance difference between TextDecoder and StringDecoder.