From 27b09c37e4295926850fa04eab95a53a8eea1541 Mon Sep 17 00:00:00 2001 From: Michael Morrison Date: Wed, 10 Jul 2013 07:20:05 -0500 Subject: [PATCH] remove iconv dependency --- package.json | 2 +- reader.js | 24 +++--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) 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; },