Coder Social home page Coder Social logo

Comments (2)

ashtuchkin avatar ashtuchkin commented on May 29, 2024

Hi!

I haven't checked it manually, but I think most names that are used in the real world will be interpreted correctly. First, names are not case sensitive in iconv-lite and all non-alphanumeric characters are stripped, as well as what seems like a year suffix (i.e. ISO_8859-1:1987 = ISO8859-1 = iso88591). Then, there are lots of aliases, for example win1251 = windows1251 = 1251 = Windows-1251.

If you have a limited set of encodings that you support, you can check them all with iconv.encodingExists(name) function. Then, you can either tell me to add an alias, or do it in your project with the following code:

var iconv = require('iconv-lite');
iconv.encode('utf8', ''); // load encoding definitions
iconv.encodings['<new alias name>'] = '<alias to what>'; // both lowercase, alphanumeric.

If, on the other hand, you want to support all IANA names and aliases, then, probably, iconv-lite is not an option because it doesn't support all the older encodings (neither do node-iconv AFAIK).

from iconv-lite.

btd avatar btd commented on May 29, 2024

Thanks, for response. My purpose is getting some possibly text content via http requests, and from headers get charset and decode them to utf-8 (i.e. that is what browsers do =), as header Content-Type: mime; charset=IANA_charset name or alias, thus i was need to know that question.
I do not want to support all encodings, it is enough most common one byte encoding and utf-8, utf-16*.
Thanks that point to . encodingExists it should be enough to see if will be any errors, just because it is missing, but i think with main encoding names, should no be problems (i have another module that resolve aliases).

from iconv-lite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.