mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 17:25:19 +01:00
remove iconv dependency
This commit is contained in:
parent
f062e03271
commit
27b09c37e4
2 changed files with 4 additions and 22 deletions
|
@ -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"
|
||||
|
|
24
reader.js
24
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;
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue