Permalink
Browse files

use iconv-lite by default

  • Loading branch information...
1 parent d912dc8 commit f8578142dd73f6f751339f6b2adfdf951c995b8c @andris9 committed Jan 12, 2013
Showing with 7 additions and 7 deletions.
  1. +3 −0 README.md
  2. +2 −5 lib/fetch.js
  3. +2 −2 package.json
View
3 README.md
@@ -31,6 +31,9 @@ Example
**NB** If the file has been marked with charset other than utf-8, it is converted automatically.
+By default `iconv-lite` is used for charset conversion. If you want to use `node-iconv` module instead,
+add `"iconv": "*"` to your package.json file, it will be picked up by `fetch` automatically.
+
## Streaming
`fetch.FetchStream(url [, options]) -> Stream`
View
7 lib/fetch.js
@@ -6,7 +6,7 @@ var http = require("http"),
dns = require('dns'),
Stream = require("stream").Stream,
CookieJar = require("./cookiejar").CookieJar,
- Iconv = require("iconv").Iconv;
+ encodinglib = require("encoding");
/*
@@ -413,10 +413,7 @@ function fetchUrl(url, options, callback){
if(!this.options.disableDecoding && !content_type.charset.match(/^utf-?8$/i)){
- try{
- convert = new Iconv(content_type.charset, "UTF-8//TRANSLIT//IGNORE");
- buffer = convert.convert(buffer);
- }catch(E){}
+ buffer = encodinglib.convert(buffer, "UTF-8", content_type.charset);
}
if(this.options.outputEncoding){
View
4 package.json
@@ -1,7 +1,7 @@
{
"name": "fetch",
"description": "Fetch URL contents",
- "version": "0.2.9",
+ "version": "0.3.0",
"author": "Andris Reinman",
"maintainers": [
"andris <andris@node.ee>"
@@ -19,7 +19,7 @@
}
],
"dependencies": {
- "iconv": "*"
+ "encoding": "*"
},
"engines": ["node >=0.5.10"],
"keywords": [

0 comments on commit f857814

Please sign in to comment.