ashtuchkin / iconv-lite

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

API to get supported encodings #289

Open eekboom opened 2 years ago

eekboom commented 2 years ago

If you want to offer the user a list of encodings, it would be nice to get that list out of icon-lite rather than hardcoding it.

ashtuchkin commented 2 years ago

We currently have iconv.encodingExists which can help in some cases, but I can see the value in having an official way to list encodings, yes. I'll try to add it before 1.0 release.

If you need it now, you can probably refer to keys of iconv.encodings after they are lazy-loaded by calling any other method. The keys are normalized (lowercased, stripped of spaces and dashes).

slugger941 commented 2 years ago

Hello I also have same requirement. I hope API to get encoding type by user locale. If user's locale is 'kr'(korea), the API return supported encoding type like KS_C_5601 or Windows949, EUC-KR. Can you support this API??

ashtuchkin commented 2 years ago

That's a different API. iconv-lite doesn't even have this information at this point.

slugger941 commented 2 years ago

Ok. Do you have any idea to support that API??or know any way to get encoding type by user locale(ISO 3166)??

ashtuchkin commented 2 years ago

Well, an obvious idea would be to create such a mapping yourself and potentially publish a npm module. At this point, I don't think it's a great fit for iconv-lite.