diff --git a/package.json b/package.json index 69c9d9a..74d0b59 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ } ], "dependencies": { - "iconv": ">=2.0.6", + "iconv-lite": ">=0.2.10", "bignum": ">=0.6.1", "async": ">=0.2.9", "compressjs": ">=1.0.0" diff --git a/reader.js b/reader.js index 8a3e043..fe9dacc 100644 --- a/reader.js +++ b/reader.js @@ -1,23 +1,6 @@ -var Iconv = require('iconv').Iconv, +var Iconv = require('iconv-lite'), Bignum = require('bignum'); - - -var Iconv_converters = {}; -function getIconv(from) { - var to = 'utf-8'; - var key = from+'---'+to; - if(!(key in Iconv_converters)) { - Iconv_converters[key] = new Iconv(from, to); - } - return Iconv_converters[key]; -} - - - - - - function Reader(query,buffer) { this.query = query; this.buffer = buffer; @@ -39,7 +22,7 @@ Reader.prototype = { } options.encoding = options.encoding || this.query.encoding; - if(options.encoding == 'latin1') options.encoding = 'windows-1252'; + if(options.encoding == 'latin1') options.encoding = 'win1252'; var start = this.i+0; var end = start; @@ -65,8 +48,7 @@ Reader.prototype = { if(enc == 'utf8' || enc == 'ucs2' || enc == 'binary') { out = out.toString(enc); } else { - var converter = getIconv(enc); - out = converter.convert(out).toString(); + out = Iconv.decode(out,enc); } return out; },