Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown encoding #27

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

Unknown encoding #27

Migrate opened this issue May 4, 2011 · 5 comments

Comments

@Migrate
Copy link

Migrate commented May 4, 2011

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
Copy link
Member

mikeal commented May 24, 2011

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 as completed May 24, 2011
@Migrate
Copy link
Author

Migrate commented May 27, 2011

Hi,

Thanks.

@JPGygax68
Copy link

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
Copy link
Member

mikeal commented Apr 29, 2013

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
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants