Unknown encoding #27

Closed
Migrate opened this Issue May 4, 2011 · 5 comments

Projects

None yet

3 participants

@Migrate

Hi,
I'm trying to fetch a web page that has latin characters and encoding set to iso-8859-15 but it doesn't work.
I always get the error: "throw new Error('Unknown encoding');"

Is this a bug or I'm I doing something wrong?
Can you tell me which encodings does it support?

Thanks.
Best regards,
Migrate

@mikeal
request member

you probably just need to set the encoding paramater:

https://github.com/mikeal/request/blob/master/README.md

valid encoding options are defined in node.js, look at the docs for http.ClientResponse.setEncoding()

@mikeal mikeal closed this May 24, 2011
@Migrate

Hi,

Thanks.

@JPGygax68

Hi!

@Migrate: I'm confused about this issue. I tried to set encoding: 'iso-8859-15' in my get() call, but I'm getting an "Unknown encoding" exception. Did this work for you?

@mikeal: I found this list of supported encodings: https://github.com/joyent/node/blob/master/lib/buffer.js#L63, and it doesn't include any ISO encodings, just Unicode. In my case, I was able to get what I need by requesting a binary response, then converting that using iconv-lite. But wouldn't it make sense to integrate this, as an option (and based on meta tag sniffing) into your request module itself?

Thanks,

Jean-Pierre

@mikeal
request member

Specific ISO encodings are useful when you're parsing the response but, most of the time, when the encoding matters this much what you actually want to do is pass the data over without parsing it at all, which is best accomplished with the default buffers.

@JPGygax68

Thank you Mikael, that makes perfect sense to me. It's just that your module is being used in a "browser-like" fashion by some other modules - in my case, I'm using the spider module to extract information from a site and convert it to XML. Spider does not use your "encoding: null" feature, nor does it attempt to adapt to the encoding, so I guess that's where I should do my complaining.

Still, as the request module is being used by many others, wouldn't it make sense to provide some sort of solution as part of this package, where it would be easy to find?

Just my two cents. Thanks again,

Jean-Pierre

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment