ashtuchkin / iconv-lite

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

UCS-2BE, UCS-2LE not supported #290

Closed eekboom closed 2 years ago

eekboom commented 2 years ago

I can use UCS-2 for encoding, but does that give me UCS-2LE or UCS-2BE? Please directly support both UCS-2LE and UCS2-BE!

ashtuchkin commented 2 years ago

Looking at https://en.wikipedia.org/wiki/Universal_Coded_Character_Set, I don't think these are standard (unlike e.g. UTF-16LE/BE). Given UCS-2 have been superseded by UTF-16 and we have both UTF-16LE and UTF-16BE available as a replacement, I think it would be better to use these latter ones.

If for some reason you need to specifically accept UCS-2BE or LE in your code, you can add an alias like this:

if (!iconv.encodingExists("ucs2be") {
    iconv.encodings["ucs2be"] = "utf16be":
    iconv.encodings["ucs2le"] = "utf16le":
}

Closing, let me know if you need anything else here.