Skip to content

Commit 4114d6f

Browse files
Gabriel Schulhofashtuchkin
Gabriel Schulhof
authored andcommittedJun 8, 2020
Remove Buffer constructor usage in tests (#197)
1 parent be44a2e commit 4114d6f

15 files changed

+193
-179
lines changed
 

‎test/big5-test.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname + '/../');
34

45
var testString = "中文abc", //unicode contains Big5-code and ascii
5-
testStringBig5Buffer = new Buffer([0xa4,0xa4,0xa4,0xe5,0x61,0x62,0x63]),
6+
testStringBig5Buffer = Buffer.from([0xa4,0xa4,0xa4,0xe5,0x61,0x62,0x63]),
67
testString2 = '測試',
7-
testStringBig5Buffer2 = new Buffer([0xb4, 0xfa, 0xb8, 0xd5]);
8+
testStringBig5Buffer2 = Buffer.from([0xb4, 0xfa, 0xb8, 0xd5]);
89

910
describe("Big5 tests", function() {
1011
it("Big5 correctly encoded/decoded", function() {
@@ -20,7 +21,7 @@ describe("Big5 tests", function() {
2021
});
2122

2223
it("Big5 file read decoded,compare with iconv result", function() {
23-
var contentBuffer = new Buffer('PEhUTUw+DQo8SEVBRD4gICAgDQoJPFRJVExFPiBtZXRhILzQxdKquqjPpc6hR6SkpOW69K22IDwvVElUTEU+DQoJPG1ldGEgSFRUUC1FUVVJVj0iQ29udGVudC1UeXBlIiBDT05URU5UPSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9YmlnNSI+DQo8L0hFQUQ+DQo8Qk9EWT4NCg0Ks2+sT6RArdPBY8XppKSk5br0rbahSTxicj4NCihUaGlzIHBhZ2UgdXNlcyBiaWc1IGNoYXJhY3RlciBzZXQuKTxicj4NCmNoYXJzZXQ9YmlnNQ0KDQo8L0JPRFk+DQo8L0hUTUw+', 'base64');
24+
var contentBuffer = Buffer.from('PEhUTUw+DQo8SEVBRD4gICAgDQoJPFRJVExFPiBtZXRhILzQxdKquqjPpc6hR6SkpOW69K22IDwvVElUTEU+DQoJPG1ldGEgSFRUUC1FUVVJVj0iQ29udGVudC1UeXBlIiBDT05URU5UPSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9YmlnNSI+DQo8L0hFQUQ+DQo8Qk9EWT4NCg0Ks2+sT6RArdPBY8XppKSk5br0rbahSTxicj4NCihUaGlzIHBhZ2UgdXNlcyBiaWc1IGNoYXJhY3RlciBzZXQuKTxicj4NCmNoYXJzZXQ9YmlnNQ0KDQo8L0JPRFk+DQo8L0hUTUw+', 'base64');
2425
var str = iconv.decode(contentBuffer, "big5");
2526
var iconvc = new (require('iconv').Iconv)('big5','utf8');
2627
assert.strictEqual(iconvc.convert(contentBuffer).toString(), str);
@@ -30,7 +31,7 @@ describe("Big5 tests", function() {
3031
// https://github.com/ashtuchkin/iconv-lite/issues/13
3132
// Reference: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP950.TXT
3233
var chars = "·×";
33-
var big5Chars = new Buffer([0xA1, 0x50, 0xA1, 0xD1]);
34+
var big5Chars = Buffer.from([0xA1, 0x50, 0xA1, 0xD1]);
3435
assert.strictEqual(iconv.encode(chars, "big5").toString('hex'), big5Chars.toString('hex'));
3536
assert.strictEqual(iconv.decode(big5Chars, "big5"), chars)
3637
});
@@ -45,9 +46,9 @@ describe("Big5 tests", function() {
4546
assert.strictEqual(iconv.encode("\u00CA\uD841\uDD47", "big5").toString('hex'), "8866fa40"); // Finished surrogate ('𠕇').
4647
assert.strictEqual(iconv.encode("\u00CA𠕇", "big5").toString('hex'), "8866fa40"); // Finished surrogate ('𠕇').
4748

48-
assert.strictEqual(iconv.decode(new Buffer('8862', 'hex'), "big5"), "\u00CA\u0304");
49-
assert.strictEqual(iconv.decode(new Buffer('8866', 'hex'), "big5"), "\u00CA");
50-
assert.strictEqual(iconv.decode(new Buffer('8866fa40', 'hex'), "big5"), "\u00CA𠕇");
49+
assert.strictEqual(iconv.decode(Buffer.from('8862', 'hex'), "big5"), "\u00CA\u0304");
50+
assert.strictEqual(iconv.decode(Buffer.from('8866', 'hex'), "big5"), "\u00CA");
51+
assert.strictEqual(iconv.decode(Buffer.from('8866fa40', 'hex'), "big5"), "\u00CA𠕇");
5152
});
5253

5354
it("Big5 correctly encodes 十", function() {

‎test/bom-test.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../');
34

45
var sampleStr = '<?xml version="1.0" encoding="UTF-8"?>\n<俄语>данные</俄语>';
56
strBOM = '\ufeff',
6-
utf8BOM = new Buffer([0xEF, 0xBB, 0xBF]),
7-
utf16beBOM = new Buffer([0xFE, 0xFF]),
8-
utf16leBOM = new Buffer([0xFF, 0xFE]);
7+
utf8BOM = Buffer.from([0xEF, 0xBB, 0xBF]),
8+
utf16beBOM = Buffer.from([0xFE, 0xFF]),
9+
utf16leBOM = Buffer.from([0xFF, 0xFE]);
910

1011
describe("BOM Handling", function() {
1112
it("strips UTF-8 BOM", function() {
12-
var body = Buffer.concat([utf8BOM, new Buffer(sampleStr)]);
13+
var body = Buffer.concat([utf8BOM, Buffer.from(sampleStr)]);
1314
assert.equal(iconv.decode(body, 'utf8'), sampleStr);
1415
});
1516

@@ -24,7 +25,7 @@ describe("BOM Handling", function() {
2425
});
2526

2627
it("doesn't strip BOMs when stripBOM=false", function() {
27-
var body = Buffer.concat([utf8BOM, new Buffer(sampleStr)]);
28+
var body = Buffer.concat([utf8BOM, Buffer.from(sampleStr)]);
2829
assert.equal(iconv.decode(body, 'utf8', {stripBOM: false}), strBOM + sampleStr);
2930

3031
var body = Buffer.concat([utf16leBOM, iconv.encode(sampleStr, 'utf16le')]);
@@ -44,7 +45,7 @@ describe("BOM Handling", function() {
4445
});
4546

4647
it("adds UTF-8 BOM when addBOM=true", function() {
47-
var body = Buffer.concat([utf8BOM, new Buffer(sampleStr)]).toString('hex');
48+
var body = Buffer.concat([utf8BOM, Buffer.from(sampleStr)]).toString('hex');
4849
assert.equal(iconv.encode(sampleStr, 'utf8', {addBOM: true}).toString('hex'), body);
4950
});
5051

@@ -69,13 +70,13 @@ describe("BOM Handling", function() {
6970
var bomStripped = false;
7071
var stripBOM = function() { bomStripped = true; }
7172

72-
var body = Buffer.concat([utf8BOM, new Buffer(sampleStr)]);
73+
var body = Buffer.concat([utf8BOM, Buffer.from(sampleStr)]);
7374
assert.equal(iconv.decode(body, 'utf8', {stripBOM: stripBOM}), sampleStr);
7475
assert(bomStripped);
7576

7677
bomStripped = false;
7778

78-
body = new Buffer(sampleStr);
79+
body = Buffer.from(sampleStr);
7980
assert.equal(iconv.decode(body, 'utf8', {stripBOM: stripBOM}), sampleStr);
8081
assert(!bomStripped);
8182
});

‎test/cesu8-test.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../');
34

45
describe("CESU-8 codec", function() {
@@ -13,11 +14,11 @@ describe("CESU-8 codec", function() {
1314
assert.equal(iconv.encode("😱😱", "cesu8").toString('hex'), "eda0bdedb8b1eda0bdedb8b1");
1415
});
1516
it("decodes correctly", function() {
16-
assert.equal(iconv.decode(new Buffer("45", 'hex'), "cesu8"), "E");
17-
assert.equal(iconv.decode(new Buffer("c2a2", 'hex'), "cesu8"), "¢");
18-
assert.equal(iconv.decode(new Buffer("c885", 'hex'), "cesu8"), "ȅ");
19-
assert.equal(iconv.decode(new Buffer("e282ac", 'hex'), "cesu8"), "€");
20-
assert.equal(iconv.decode(new Buffer("eda081edb080", 'hex'), "cesu8"), "𐐀");
21-
assert.equal(iconv.decode(new Buffer("eda0bdedb8b1", 'hex'), "cesu8"), "😱");
17+
assert.equal(iconv.decode(Buffer.from("45", 'hex'), "cesu8"), "E");
18+
assert.equal(iconv.decode(Buffer.from("c2a2", 'hex'), "cesu8"), "¢");
19+
assert.equal(iconv.decode(Buffer.from("c885", 'hex'), "cesu8"), "ȅ");
20+
assert.equal(iconv.decode(Buffer.from("e282ac", 'hex'), "cesu8"), "€");
21+
assert.equal(iconv.decode(Buffer.from("eda081edb080", 'hex'), "cesu8"), "𐐀");
22+
assert.equal(iconv.decode(Buffer.from("eda0bdedb8b1", 'hex'), "cesu8"), "😱");
2223
});
2324
});

‎test/cyrillic-test.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../');
34

45
var baseStrings = {
@@ -17,31 +18,31 @@ var encodings = [{
1718
name: "Win-1251",
1819
variations: ['win1251', 'Windows-1251', 'windows1251', 'CP1251', 1251],
1920
encodedStrings: {
20-
empty: new Buffer(''),
21-
hi: new Buffer('\xcf\xf0\xe8\xe2\xe5\xf2!', 'binary'),
22-
ascii: new Buffer(baseStrings.ascii, 'binary'),
23-
rus: new Buffer('\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff', 'binary'),
24-
additional1: new Buffer('\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf','binary'),
21+
empty: Buffer.from(''),
22+
hi: Buffer.from('\xcf\xf0\xe8\xe2\xe5\xf2!', 'binary'),
23+
ascii: Buffer.from(baseStrings.ascii, 'binary'),
24+
rus: Buffer.from('\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff', 'binary'),
25+
additional1: Buffer.from('\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf','binary'),
2526
}
2627
}, {
2728
name: "Koi8-R",
2829
variations: ['koi8r', 'KOI8-R', 'cp20866', 20866],
2930
encodedStrings: {
30-
empty: new Buffer(''),
31-
hi: new Buffer('\xf0\xd2\xc9\xd7\xc5\xd4!', 'binary'),
32-
ascii: new Buffer(baseStrings.ascii, 'binary'),
33-
rus: new Buffer('\xe1\xe2\xf7\xe7\xe4\xe5\xf6\xfa\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf2\xf3\xf4\xf5\xe6\xe8\xe3\xfe\xfb\xfd\xff\xf9\xf8\xfc\xe0\xf1\xc1\xc2\xd7\xc7\xc4\xc5\xd6\xda\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd2\xd3\xd4\xd5\xc6\xc8\xc3\xde\xdb\xdd\xdf\xd9\xd8\xdc\xc0\xd1', 'binary'),
34-
additional2: new Buffer('\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf', 'binary'),
31+
empty: Buffer.from(''),
32+
hi: Buffer.from('\xf0\xd2\xc9\xd7\xc5\xd4!', 'binary'),
33+
ascii: Buffer.from(baseStrings.ascii, 'binary'),
34+
rus: Buffer.from('\xe1\xe2\xf7\xe7\xe4\xe5\xf6\xfa\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf2\xf3\xf4\xf5\xe6\xe8\xe3\xfe\xfb\xfd\xff\xf9\xf8\xfc\xe0\xf1\xc1\xc2\xd7\xc7\xc4\xc5\xd6\xda\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd2\xd3\xd4\xd5\xc6\xc8\xc3\xde\xdb\xdd\xdf\xd9\xd8\xdc\xc0\xd1', 'binary'),
35+
additional2: Buffer.from('\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf', 'binary'),
3536
}
3637
}, {
3738
name: "ISO 8859-5",
3839
variations: ['iso88595', 'ISO-8859-5', 'ISO 8859-5', 'cp28595', 28595],
3940
encodedStrings: {
40-
empty: new Buffer(''),
41-
hi: new Buffer('\xbf\xe0\xd8\xd2\xd5\xe2!', 'binary'),
42-
ascii: new Buffer(baseStrings.ascii, 'binary'),
43-
rus: new Buffer('\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef', 'binary'),
44-
additional3: new Buffer('\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff', 'binary'),
41+
empty: Buffer.from(''),
42+
hi: Buffer.from('\xbf\xe0\xd8\xd2\xd5\xe2!', 'binary'),
43+
ascii: Buffer.from(baseStrings.ascii, 'binary'),
44+
rus: Buffer.from('\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef', 'binary'),
45+
additional3: Buffer.from('\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff', 'binary'),
4546
}
4647
}];
4748

‎test/dbcs-test.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var fs = require('fs'),
22
assert = require('assert'),
3+
Buffer = require('safer-buffer').Buffer,
34
iconv = require(__dirname+'/../'),
45
Iconv = require('iconv').Iconv;
56

@@ -8,7 +9,7 @@ var fs = require('fs'),
89
// fn(valid, input, output)
910
function forAllChars(converter, fn, origbuf, len) {
1011
if (!origbuf) {
11-
origbuf = new Buffer(10);
12+
origbuf = Buffer.alloc(10);
1213
len = 1;
1314
}
1415
if (!converter.chars) converter.chars = 1;
@@ -45,7 +46,7 @@ function convertWithDefault(converter, buf) {
4546
if (e.code != "EILSEQ")
4647
throw e;
4748
}
48-
return new Buffer(iconv.defaultCharSingleByte);
49+
return Buffer.from(iconv.defaultCharSingleByte);
4950
}
5051

5152
var aliases = {
@@ -145,7 +146,7 @@ var iconvCannotDecode = { // Characters that we can decode, but iconv cannot. En
145146
function swapBytes(buf) { for (var i = 0; i < buf.length; i+=2) buf.writeUInt16LE(buf.readUInt16BE(i), i); return buf; }
146147
function spacify2(str) { return str.replace(/(..)/g, "$1 ").trim(); }
147148
function spacify4(str) { return str.replace(/(....)/g, "$1 ").trim(); }
148-
function strToHex(str) { return spacify4(swapBytes(new Buffer(str, 'ucs2')).toString('hex')); }
149+
function strToHex(str) { return spacify4(swapBytes(Buffer.from(str, 'ucs2')).toString('hex')); }
149150

150151
// Generate tests for all DBCS encodings.
151152
iconv.encode('', 'utf8'); // Load all encodings.

‎test/gbk-test.js

+24-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
var fs = require('fs'),
22
assert = require('assert'),
3+
Buffer = require('safer-buffer').Buffer,
34
iconv = require(__dirname+'/../');
45

56
var testString = "中国abc",//unicode contains GBK-code and ascii
6-
testStringGBKBuffer = new Buffer([0xd6,0xd0,0xb9,0xfa,0x61,0x62,0x63]);
7+
testStringGBKBuffer = Buffer.from([0xd6,0xd0,0xb9,0xfa,0x61,0x62,0x63]);
78

89
describe("GBK tests", function() {
910
it("GBK correctly encoded/decoded", function() {
@@ -27,7 +28,7 @@ describe("GBK tests", function() {
2728
// https://github.com/ashtuchkin/iconv-lite/issues/13
2829
// Reference: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP936.TXT
2930
var chars = "·×";
30-
var gbkChars = new Buffer([0xA1, 0xA4, 0xA1, 0xC1]);
31+
var gbkChars = Buffer.from([0xA1, 0xA4, 0xA1, 0xC1]);
3132
assert.strictEqual(iconv.encode(chars, "GBK").toString('binary'), gbkChars.toString('binary'));
3233
assert.strictEqual(iconv.decode(gbkChars, "GBK"), chars)
3334
});
@@ -36,8 +37,8 @@ describe("GBK tests", function() {
3637
// Euro character (U+20AC) has two encodings in GBK family: 0x80 and 0xA2 0xE3
3738
// According to W3C's technical recommendation (https://www.w3.org/TR/encoding/#gbk-encoder),
3839
// Both GBK and GB18030 decoders should accept both encodings.
39-
var gbkEuroEncoding1 = new Buffer([0x80]),
40-
gbkEuroEncoding2 = new Buffer([0xA2, 0xE3]),
40+
var gbkEuroEncoding1 = Buffer.from([0x80]),
41+
gbkEuroEncoding2 = Buffer.from([0xA2, 0xE3]),
4142
strEuro = "€";
4243

4344
assert.strictEqual(iconv.decode(gbkEuroEncoding1, "GBK"), strEuro);
@@ -70,16 +71,16 @@ describe("GBK tests", function() {
7071

7172
function swapBytes(buf) { for (var i = 0; i < buf.length; i+=2) buf.writeUInt16LE(buf.readUInt16BE(i), i); return buf; }
7273
function spacify4(str) { return str.replace(/(....)/g, "$1 ").trim(); }
73-
function strToHex(str) { return spacify4(swapBytes(new Buffer(str, 'ucs2')).toString('hex')); }
74+
function strToHex(str) { return spacify4(swapBytes(Buffer.from(str, 'ucs2')).toString('hex')); }
7475

7576
it("GB18030 encodes/decodes 4 byte sequences", function() {
7677
var chars = {
77-
"\u0080": new Buffer([0x81, 0x30, 0x81, 0x30]),
78-
"\u0081": new Buffer([0x81, 0x30, 0x81, 0x31]),
79-
"\u008b": new Buffer([0x81, 0x30, 0x82, 0x31]),
80-
"\u0615": new Buffer([0x81, 0x31, 0x82, 0x31]),
81-
"\u399f": new Buffer([0x82, 0x31, 0x82, 0x31]),
82-
"\udbd9\ude77": new Buffer([0xE0, 0x31, 0x82, 0x31]),
78+
"\u0080": Buffer.from([0x81, 0x30, 0x81, 0x30]),
79+
"\u0081": Buffer.from([0x81, 0x30, 0x81, 0x31]),
80+
"\u008b": Buffer.from([0x81, 0x30, 0x82, 0x31]),
81+
"\u0615": Buffer.from([0x81, 0x31, 0x82, 0x31]),
82+
"\u399f": Buffer.from([0x82, 0x31, 0x82, 0x31]),
83+
"\udbd9\ude77": Buffer.from([0xE0, 0x31, 0x82, 0x31]),
8384
};
8485
for (var uChar in chars) {
8586
var gbkBuf = chars[uChar];
@@ -90,18 +91,18 @@ describe("GBK tests", function() {
9091

9192
it("GB18030 correctly decodes incomplete 4 byte sequences", function() {
9293
var chars = {
93-
"�": new Buffer([0x82]),
94-
"�1": new Buffer([0x82, 0x31]),
95-
"�1�": new Buffer([0x82, 0x31, 0x82]),
96-
"\u399f": new Buffer([0x82, 0x31, 0x82, 0x31]),
97-
"� ": new Buffer([0x82, 0x20]),
98-
"�1 ": new Buffer([0x82, 0x31, 0x20]),
99-
"�1� ": new Buffer([0x82, 0x31, 0x82, 0x20]),
100-
"\u399f ": new Buffer([0x82, 0x31, 0x82, 0x31, 0x20]),
101-
"�1\u4fdb": new Buffer([0x82, 0x31, 0x82, 0x61]),
102-
"�1\u5010\u0061": new Buffer([0x82, 0x31, 0x82, 0x82, 0x61]),
103-
"\u399f\u4fdb": new Buffer([0x82, 0x31, 0x82, 0x31, 0x82, 0x61]),
104-
"�1\u50101�1": new Buffer([0x82, 0x31, 0x82, 0x82, 0x31, 0x82, 0x31]),
94+
"�": Buffer.from([0x82]),
95+
"�1": Buffer.from([0x82, 0x31]),
96+
"�1�": Buffer.from([0x82, 0x31, 0x82]),
97+
"\u399f": Buffer.from([0x82, 0x31, 0x82, 0x31]),
98+
"� ": Buffer.from([0x82, 0x20]),
99+
"�1 ": Buffer.from([0x82, 0x31, 0x20]),
100+
"�1� ": Buffer.from([0x82, 0x31, 0x82, 0x20]),
101+
"\u399f ": Buffer.from([0x82, 0x31, 0x82, 0x31, 0x20]),
102+
"�1\u4fdb": Buffer.from([0x82, 0x31, 0x82, 0x61]),
103+
"�1\u5010\u0061": Buffer.from([0x82, 0x31, 0x82, 0x82, 0x61]),
104+
"\u399f\u4fdb": Buffer.from([0x82, 0x31, 0x82, 0x31, 0x82, 0x61]),
105+
"�1\u50101�1": Buffer.from([0x82, 0x31, 0x82, 0x82, 0x31, 0x82, 0x31]),
105106
};
106107
for (var uChar in chars) {
107108
var gbkBuf = chars[uChar];

‎test/greek-test.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../');
34

45
var baseStrings = {
@@ -14,28 +15,28 @@ var encodings = [{
1415
name: "windows1253",
1516
variations: ['windows-1253', 'win-1253', 'win1253', 'cp1253', 'cp-1253', 1253],
1617
encodedStrings: {
17-
empty: new Buffer(''),
18-
hi: new Buffer('\xc3\xe5\xe9\xdc!', 'binary'),
19-
ascii: new Buffer(baseStrings.ascii, 'binary'),
20-
greek: new Buffer('\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xdc\xdd\xde\xdf\xfc\xfd\xfe\xa2\xb8\xb9\xba\xbc\xbe\xbf\xfa\xfb\xda\xdb', 'binary'),
18+
empty: Buffer.from(''),
19+
hi: Buffer.from('\xc3\xe5\xe9\xdc!', 'binary'),
20+
ascii: Buffer.from(baseStrings.ascii, 'binary'),
21+
greek: Buffer.from('\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xdc\xdd\xde\xdf\xfc\xfd\xfe\xa2\xb8\xb9\xba\xbc\xbe\xbf\xfa\xfb\xda\xdb', 'binary'),
2122
}
2223
}, {
2324
name: "iso88597",
2425
variations: ['iso-8859-7', 'greek', 'greek8', 'cp28597', 'cp-28597', 28597],
2526
encodedStrings: {
26-
empty: new Buffer(''),
27-
hi: new Buffer('\xc3\xe5\xe9\xdc!', 'binary'),
28-
ascii: new Buffer(baseStrings.ascii, 'binary'),
29-
greek: new Buffer('\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xdc\xdd\xde\xdf\xfc\xfd\xfe\xb6\xb8\xb9\xba\xbc\xbe\xbf\xfa\xfb\xda\xdb', 'binary'),
27+
empty: Buffer.from(''),
28+
hi: Buffer.from('\xc3\xe5\xe9\xdc!', 'binary'),
29+
ascii: Buffer.from(baseStrings.ascii, 'binary'),
30+
greek: Buffer.from('\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xdc\xdd\xde\xdf\xfc\xfd\xfe\xb6\xb8\xb9\xba\xbc\xbe\xbf\xfa\xfb\xda\xdb', 'binary'),
3031
}
3132
}, {
3233
name: "cp737",
3334
variations: ['cp-737', 737],
3435
encodedStrings: {
35-
empty: new Buffer(''),
36-
hi: new Buffer('\x82\x9c\xa0\xe1!', 'binary'),
37-
ascii: new Buffer(baseStrings.ascii, 'binary'),
38-
greek: new Buffer('\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xab\xac\xad\xae\xaf\xe0\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\xe1\xe2\xe3\xe5\xe6\xe7\xe9\xea\xeb\xec\xed\xee\xef\xf0\xe4\xe8\xf4\xf5', 'binary'),
36+
empty: Buffer.from(''),
37+
hi: Buffer.from('\x82\x9c\xa0\xe1!', 'binary'),
38+
ascii: Buffer.from(baseStrings.ascii, 'binary'),
39+
greek: Buffer.from('\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xab\xac\xad\xae\xaf\xe0\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\xe1\xe2\xe3\xe5\xe6\xe7\xe9\xea\xeb\xec\xed\xee\xef\xf0\xe4\xe8\xf4\xf5', 'binary'),
3940
}
4041
}];
4142

‎test/main-test.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../');
34

45
var testString = "Hello123!";
@@ -9,43 +10,43 @@ var testStringHex = "48656c6c6f31323321";
910
describe("Generic UTF8-UCS2 tests", function() {
1011

1112
it("Return values are of correct types", function() {
12-
assert.ok(iconv.encode(testString, "utf8") instanceof Buffer);
13+
assert.ok(Buffer.isBuffer(iconv.encode(testString, "utf8")));
1314

14-
var s = iconv.decode(new Buffer(testString), "utf8");
15+
var s = iconv.decode(Buffer.from(testString), "utf8");
1516
assert.strictEqual(Object.prototype.toString.call(s), "[object String]");
1617
});
1718

1819
it("Internal encodings all correctly encoded/decoded", function() {
1920
['utf8', "UTF-8", "UCS2", "binary"].forEach(function(enc) {
2021
assert.strictEqual(iconv.encode(testStringLatin1, enc).toString(enc), testStringLatin1);
21-
assert.strictEqual(iconv.decode(new Buffer(testStringLatin1, enc), enc), testStringLatin1);
22+
assert.strictEqual(iconv.decode(Buffer.from(testStringLatin1, enc), enc), testStringLatin1);
2223
});
2324
});
2425

2526
it("Base64 correctly encoded/decoded", function() {
2627
assert.strictEqual(iconv.encode(testStringBase64, "base64").toString("binary"), testString);
27-
assert.strictEqual(iconv.decode(new Buffer(testString, "binary"), "base64"), testStringBase64);
28+
assert.strictEqual(iconv.decode(Buffer.from(testString, "binary"), "base64"), testStringBase64);
2829
});
2930

3031
it("Hex correctly encoded/decoded", function() {
3132
assert.strictEqual(iconv.encode(testStringHex, "hex").toString("binary"), testString);
32-
assert.strictEqual(iconv.decode(new Buffer(testString, "binary"), "hex"), testStringHex);
33+
assert.strictEqual(iconv.decode(Buffer.from(testString, "binary"), "hex"), testStringHex);
3334
});
3435

3536
it("Latin1 correctly encoded/decoded", function() {
3637
assert.strictEqual(iconv.encode(testStringLatin1, "latin1").toString("binary"), testStringLatin1);
37-
assert.strictEqual(iconv.decode(new Buffer(testStringLatin1, "binary"), "latin1"), testStringLatin1);
38+
assert.strictEqual(iconv.decode(Buffer.from(testStringLatin1, "binary"), "latin1"), testStringLatin1);
3839
});
3940

4041
it("Convert to string, not buffer (utf8 used)", function() {
41-
var res = iconv.encode(new Buffer(testStringLatin1, "utf8"), "utf8");
42-
assert.ok(res instanceof Buffer);
42+
var res = iconv.encode(Buffer.from(testStringLatin1, "utf8"), "utf8");
43+
assert.ok(Buffer.isBuffer(res));
4344
assert.strictEqual(res.toString("utf8"), testStringLatin1);
4445
});
4546

4647
it("Throws on unknown encodings", function() {
4748
assert.throws(function() { iconv.encode("a", "xxx"); });
48-
assert.throws(function() { iconv.decode(new Buffer("a"), "xxx"); });
49+
assert.throws(function() { iconv.decode(Buffer.from("a"), "xxx"); });
4950
});
5051

5152
it("Convert non-strings and non-buffers", function() {
@@ -56,7 +57,7 @@ describe("Generic UTF8-UCS2 tests", function() {
5657

5758
it("Aliases toEncoding and fromEncoding work the same as encode and decode", function() {
5859
assert.strictEqual(iconv.toEncoding(testString, "latin1").toString("binary"), iconv.encode(testString, "latin1").toString("binary"));
59-
assert.strictEqual(iconv.fromEncoding(new Buffer(testStringLatin1), "latin1"), iconv.decode(new Buffer(testStringLatin1), "latin1"));
60+
assert.strictEqual(iconv.fromEncoding(Buffer.from(testStringLatin1), "latin1"), iconv.decode(Buffer.from(testStringLatin1), "latin1"));
6061
});
6162

6263
it("handles Object & Array prototypes monkey patching", function() {
@@ -65,10 +66,10 @@ describe("Generic UTF8-UCS2 tests", function() {
6566

6667
iconv._codecDataCache = {}; // Clean up cache so that all encodings are loaded.
6768

68-
assert.strictEqual(iconv.decode(new Buffer("abc"), "gbk"), "abc");
69-
assert.strictEqual(iconv.decode(new Buffer("abc"), "win1251"), "abc");
70-
assert.strictEqual(iconv.decode(new Buffer("abc"), "utf7"), "abc");
71-
assert.strictEqual(iconv.decode(new Buffer("abc"), "utf8"), "abc");
69+
assert.strictEqual(iconv.decode(Buffer.from("abc"), "gbk"), "abc");
70+
assert.strictEqual(iconv.decode(Buffer.from("abc"), "win1251"), "abc");
71+
assert.strictEqual(iconv.decode(Buffer.from("abc"), "utf7"), "abc");
72+
assert.strictEqual(iconv.decode(Buffer.from("abc"), "utf8"), "abc");
7273

7374
assert.strictEqual(iconv.encode("abc", "gbk").toString(), "abc");
7475
assert.strictEqual(iconv.encode("abc", "win1251").toString(), "abc");

‎test/sbcs-test.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var assert = require('assert'),
22
unorm = require('unorm'),
3+
Buffer = require('safer-buffer').Buffer,
34
iconv = require(__dirname+'/../'),
45
Iconv = require('iconv').Iconv;
56

@@ -43,7 +44,7 @@ var iconvEquivChars = {
4344
function swapBytes(buf) { for (var i = 0; i < buf.length; i+=2) buf.writeUInt16LE(buf.readUInt16BE(i), i); return buf; }
4445
function spacify2(str) { return str.replace(/(..)/g, "$1 ").trim(); }
4546
function spacify4(str) { return str.replace(/(....)/g, "$1 ").trim(); }
46-
function strToHex(str) { return spacify4(swapBytes(new Buffer(str, 'ucs2')).toString('hex')); }
47+
function strToHex(str) { return spacify4(swapBytes(Buffer.from(str, 'ucs2')).toString('hex')); }
4748

4849
// Generate tests for all SBCS encodings.
4950
iconv.encode('', 'utf8'); // Load all encodings.
@@ -66,7 +67,7 @@ describe("Full SBCS encoding tests", function() {
6667
}
6768
var errors = [];
6869
for (var i = 0; i < 0x100; i++) {
69-
var buf = new Buffer([i]);
70+
var buf = Buffer.from([i]);
7071
var strActual = iconv.decode(buf, enc);
7172
var strExpected = convertWithDefault(conv, buf, iconv.defaultCharUnicode).toString();
7273

@@ -93,7 +94,7 @@ describe("Full SBCS encoding tests", function() {
9394
if (i == 0xD800) i = 0xF900; // Skip surrogates & private use
9495

9596
var str = String.fromCharCode(i);
96-
var strExpected = convertWithDefault(conv, str, new Buffer(iconv.defaultCharSingleByte)).toString('hex');
97+
var strExpected = convertWithDefault(conv, str, Buffer.from(iconv.defaultCharSingleByte)).toString('hex');
9798
var strActual = iconv.encode(str, enc).toString('hex');
9899

99100
if (strExpected == strActual)
@@ -148,13 +149,13 @@ describe("Full SBCS encoding tests", function() {
148149
// TODO: Implement unicode composition. After that, this test will be meaningful.
149150
150151
// Create a large random text.
151-
var buf2 = new Buffer(100);
152+
var buf2 = Buffer.alloc(100);
152153
for (var i = 0; i < buf2.length; i++)
153154
buf2[i] = buf[(Math.random()*buf.length) | 0];
154155
155156
// Check both encoding and decoding.
156157
assert.strictEqual(JSON.stringify(iconv.decode(buf2, enc)), JSON.stringify(str = conv.convert(buf2).toString()));
157-
assert.strictEqual(iconv.encode(str, enc).toString('hex'), convBack.convert(new Buffer(str)).toString('hex'));
158+
assert.strictEqual(iconv.encode(str, enc).toString('hex'), convBack.convert(Buffer.from(str)).toString('hex'));
158159
*/
159160
})(enc);
160161
});

‎test/shiftjis-test.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname + '/../');
34

45
describe("ShiftJIS tests", function() {
56
it("ShiftJIS correctly encoded/decoded", function() {
67
var testString = "中文abc", //unicode contains ShiftJIS-code and ascii
7-
testStringBig5Buffer = new Buffer([0x92, 0x86, 0x95, 0xb6, 0x61, 0x62, 0x63]),
8+
testStringBig5Buffer = Buffer.from([0x92, 0x86, 0x95, 0xb6, 0x61, 0x62, 0x63]),
89
testString2 = '測試',
9-
testStringBig5Buffer2 = new Buffer([0x91, 0xaa, 0x8e, 0x8e]);
10+
testStringBig5Buffer2 = Buffer.from([0x91, 0xaa, 0x8e, 0x8e]);
1011

1112
assert.strictEqual(iconv.encode(testString, "shiftjis").toString('hex'), testStringBig5Buffer.toString('hex'));
1213
assert.strictEqual(iconv.decode(testStringBig5Buffer, "shiftjis"), testString);
@@ -15,8 +16,8 @@ describe("ShiftJIS tests", function() {
1516
});
1617

1718
it("ShiftJIS extended chars are decoded, but not encoded", function() {
18-
var buf = new Buffer('ed40eefceeef', 'hex'), str = "纊"ⅰ", res = "fa5cfa57fa40", // repeated block (these same chars are repeated in the different place)
19-
buf2 = new Buffer('f040f2fcf940', 'hex'), str2 = "", res2 = "3f3f3f"; // non-repeated, UA block.
19+
var buf = Buffer.from('ed40eefceeef', 'hex'), str = "纊"ⅰ", res = "fa5cfa57fa40", // repeated block (these same chars are repeated in the different place)
20+
buf2 = Buffer.from('f040f2fcf940', 'hex'), str2 = "", res2 = "3f3f3f"; // non-repeated, UA block.
2021

2122
assert.strictEqual(iconv.decode(buf, "shiftjis"), str);
2223
assert.strictEqual(iconv.decode(buf2, "shiftjis"), str2);
@@ -26,7 +27,7 @@ describe("ShiftJIS tests", function() {
2627
});
2728

2829
it("ShiftJIS includes extensions", function() {
29-
assert.strictEqual(iconv.decode(new Buffer('8740', 'hex'), 'shiftjis'), '①');
30+
assert.strictEqual(iconv.decode(Buffer.from('8740', 'hex'), 'shiftjis'), '①');
3031
assert.strictEqual(iconv.encode('①', 'shiftjis').toString('hex'), '8740');
3132
});
3233
});

‎test/streams-test.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
semver = require('semver'),
34
iconv = require(__dirname+'/../');
45

56
if (!iconv.supportsStreams)
67
return;
78

8-
var Readable = require('stream').Readable,
9-
Writable = require('stream').Writable;
9+
var Readable = require('stream').Readable;
1010

1111
// Create a source stream that feeds given array of chunks.
1212
function feeder(chunks) {
@@ -22,7 +22,7 @@ function feeder(chunks) {
2222
if (chunks.length > 0) {
2323
var chunk = chunks.shift();
2424
if (Array.isArray(chunk))
25-
chunk = new Buffer(chunk);
25+
chunk = Buffer.from(chunk);
2626
stream.push(chunk, opts.encoding);
2727
} else {
2828
stream.push(null);
@@ -56,7 +56,7 @@ function checkStreamOutput(options) {
5656
while ((chunk = stream.read()) != null) {
5757
if (options.outputType)
5858
if (/^buffer/.test(options.outputType))
59-
assert(chunk instanceof Buffer);
59+
assert(Buffer.isBuffer(chunk));
6060
else
6161
assert.strictEqual(typeof chunk, options.outputType);
6262
res.push(chunk);
@@ -156,25 +156,25 @@ describe("Streaming mode", function() {
156156
it("Simple stream encoding", checkEncodeStream({
157157
encoding: "us-ascii",
158158
input: ["hello ", "world!"],
159-
output: new Buffer("hello world!"),
159+
output: Buffer.from("hello world!"),
160160
}));
161161

162162
it("Simple stream decoding", checkDecodeStream({
163163
encoding: "us-ascii",
164-
input: [new Buffer("hello "), new Buffer("world!")],
164+
input: [Buffer.from("hello "), Buffer.from("world!")],
165165
output: "hello world!",
166166
}));
167167

168168
it("Stream encoder should error when fed with buffers", checkEncodeStream({
169169
encoding: "us-ascii",
170-
input: [new Buffer("hello "), new Buffer("world!")],
170+
input: [Buffer.from("hello "), Buffer.from("world!")],
171171
checkError: /Iconv encoding stream needs strings as its input/,
172172
}));
173173

174174
it("Stream decoder should be ok when fed with strings", checkDecodeStream({
175175
encoding: "us-ascii",
176176
input: ["hello ", "world!"],
177-
output: new Buffer("hello world!"),
177+
output: Buffer.from("hello world!"),
178178
}));
179179

180180
it("Stream decoder should be error when fed with strings and 'decodeStrings: false' option is given", checkDecodeStream({
@@ -277,24 +277,24 @@ describe("Streaming mode", function() {
277277
it("Encoding base64 between chunks", checkEncodeStream({
278278
encoding: "base64",
279279
input: ['aGV', 'sbG8gd2', '9ybGQ='],
280-
output: new Buffer('hello world').toString('hex')
280+
output: Buffer.from('hello world').toString('hex')
281281
}));
282282

283283
it("Decoding of UTF-7 with base64 between chunks", checkDecodeStream({
284284
encoding: "UTF-7",
285-
input: [new Buffer('+T2'), new Buffer('BZf'), new Buffer('Q hei+AN8-t')],
285+
input: [Buffer.from('+T2'), Buffer.from('BZf'), Buffer.from('Q hei+AN8-t')],
286286
output: '\u4F60\u597D heißt'
287287
}));
288288

289289
it("Encoding of UTF-7-IMAP with base64 between chunks", checkEncodeStream({
290290
encoding: "UTF-7-IMAP",
291291
input: ['\uffff','\uedca','\u9876','\u5432','\u1fed'],
292-
output: new Buffer('&,,,typh2VDIf7Q-').toString('hex')
292+
output: Buffer.from('&,,,typh2VDIf7Q-').toString('hex')
293293
}));
294294

295295
it("Decoding of UTF-7-IMAP with base64 between chunks", checkDecodeStream({
296296
encoding: "UTF-7-IMAP",
297-
input: [new Buffer('&T2'), new Buffer('BZf'), new Buffer('Q hei&AN8-t')],
297+
input: [Buffer.from('&T2'), Buffer.from('BZf'), Buffer.from('Q hei&AN8-t')],
298298
output: '\u4F60\u597D heißt'
299299
}));
300300
});
@@ -315,7 +315,7 @@ describe("Streaming sugar", function() {
315315
.pipe(iconv.encodeStream('windows-1251'))
316316
.collect(function(err, outp) {
317317
assert.ifError(err);
318-
assert(outp instanceof Buffer);
318+
assert(Buffer.isBuffer(outp));
319319
assert.equal(outp.toString('hex'), "e0e1e2e3e4e5");
320320
done();
321321
});

‎test/turkish-test.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../');
34

45
var ascii = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'+
@@ -14,9 +15,9 @@ var encodings = [{
1415
untranslatable: "\x81\x8d\x8e\x8f\x90\x9d\x9e"
1516
},
1617
encodedStrings: {
17-
empty: new Buffer(''),
18-
ascii: new Buffer(ascii, 'binary'),
19-
turkish: new Buffer(
18+
empty: Buffer.from(''),
19+
ascii: Buffer.from(ascii, 'binary'),
20+
turkish: Buffer.from(
2021
'\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c' +
2122
'\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9f' +
2223
'\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xae\xaf' +
@@ -37,9 +38,9 @@ var encodings = [{
3738
untranslatable: ''
3839
},
3940
encodedStrings: {
40-
empty: new Buffer(''),
41-
ascii: new Buffer(ascii, 'binary'),
42-
turkish: new Buffer(
41+
empty: Buffer.from(''),
42+
ascii: Buffer.from(ascii, 'binary'),
43+
turkish: Buffer.from(
4344
'\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf' +
4445
'\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf' +
4546
'\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf' +

‎test/utf16-test.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../');
34

45
var testStr = "1aя中文☃💩";
5-
utf16beBuf = new Buffer([0, 0x31, 0, 0x61, 0x04, 0x4f, 0x4e, 0x2d, 0x65, 0x87, 0x26, 0x03, 0xd8, 0x3d, 0xdc, 0xa9]),
6-
utf16leBuf = new Buffer(testStr, 'ucs2'),
7-
utf16beBOM = new Buffer([0xFE, 0xFF]),
8-
utf16leBOM = new Buffer([0xFF, 0xFE]),
6+
utf16beBuf = Buffer.from([0, 0x31, 0, 0x61, 0x04, 0x4f, 0x4e, 0x2d, 0x65, 0x87, 0x26, 0x03, 0xd8, 0x3d, 0xdc, 0xa9]),
7+
utf16leBuf = Buffer.from(testStr, 'ucs2'),
8+
utf16beBOM = Buffer.from([0xFE, 0xFF]),
9+
utf16leBOM = Buffer.from([0xFF, 0xFE]),
910
sampleStr = '<?xml version="1.0" encoding="UTF-8"?>\n<俄语>данные</俄语>';
1011

1112
describe("UTF-16BE codec", function() {
@@ -18,7 +19,7 @@ describe("UTF-16BE codec", function() {
1819
});
1920

2021
it("decodes uneven length buffers with no error", function() {
21-
assert.equal(iconv.decode(new Buffer([0, 0x61, 0]), 'UTF16-BE'), "a");
22+
assert.equal(iconv.decode(Buffer.from([0, 0x61, 0]), 'UTF16-BE'), "a");
2223
});
2324
});
2425

@@ -29,7 +30,7 @@ describe("UTF-16 encoder", function() {
2930

3031
it("can use other encodings, for example UTF-16LE, with BOM", function() {
3132
assert.equal(iconv.encode(testStr, "utf-16", {use: 'UTF-16LE'}).toString('hex'),
32-
utf16leBOM.toString('hex') + new Buffer(testStr, 'ucs2').toString('hex'));
33+
utf16leBOM.toString('hex') + Buffer.from(testStr, 'ucs2').toString('hex'));
3334
});
3435
});
3536

@@ -40,8 +41,8 @@ describe("UTF-16 decoder", function() {
4041
});
4142

4243
it("handles very short buffers nice", function() {
43-
assert.equal(iconv.decode(new Buffer([]), 'utf-16'), '');
44-
assert.equal(iconv.decode(new Buffer([0x61]), 'utf-16'), '');
44+
assert.equal(iconv.decode(Buffer.from([]), 'utf-16'), '');
45+
assert.equal(iconv.decode(Buffer.from([0x61]), 'utf-16'), '');
4546
});
4647

4748
it("uses spaces when there is no BOM to determine encoding", function() {
@@ -56,4 +57,4 @@ describe("UTF-16 decoder", function() {
5657
it("can be given a different default encoding", function() {
5758
assert.equal(iconv.decode(utf16leBuf, 'utf-16', {default: 'utf-16le'}), testStr);
5859
});
59-
});
60+
});

‎test/utf32-test.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../'),
34
Iconv = require('iconv').Iconv;
45

56
var testStr = '1aя中文☃💩',
67
testStr2 = '❝Stray high \uD977😱 and low\uDDDD☔ surrogate values.❞',
7-
utf32leBuf = new Buffer([0x31, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x4F, 0x04, 0x00, 0x00,
8+
utf32leBuf = Buffer.from([0x31, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x4F, 0x04, 0x00, 0x00,
89
0x2D, 0x4E, 0x00, 0x00, 0x87, 0x65, 0x00, 0x00, 0x03, 0x26, 0x00, 0x00, 0xA9, 0xF4, 0x01, 0x00]),
9-
utf32beBuf = new Buffer([0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x04, 0x4F,
10+
utf32beBuf = Buffer.from([0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x04, 0x4F,
1011
0x00, 0x00, 0x4E, 0x2D, 0x00, 0x00, 0x65, 0x87, 0x00, 0x00, 0x26, 0x03, 0x00, 0x01, 0xF4, 0xA9]),
11-
utf32leBOM = new Buffer([0xFF, 0xFE, 0x00, 0x00]),
12-
utf32beBOM = new Buffer([0x00, 0x00, 0xFE, 0xFF]),
12+
utf32leBOM = Buffer.from([0xFF, 0xFE, 0x00, 0x00]),
13+
utf32beBOM = Buffer.from([0x00, 0x00, 0xFE, 0xFF]),
1314
utf32leBufWithBOM = Buffer.concat([utf32leBOM, utf32leBuf]),
1415
utf32beBufWithBOM = Buffer.concat([utf32beBOM, utf32beBuf]),
15-
utf32leBufWithInvalidChar = Buffer.concat([utf32leBuf, new Buffer([0x12, 0x34, 0x56, 0x78])]),
16-
utf32beBufWithInvalidChar = Buffer.concat([utf32beBuf, new Buffer([0x12, 0x34, 0x56, 0x78])]),
16+
utf32leBufWithInvalidChar = Buffer.concat([utf32leBuf, Buffer.from([0x12, 0x34, 0x56, 0x78])]),
17+
utf32beBufWithInvalidChar = Buffer.concat([utf32beBuf, Buffer.from([0x12, 0x34, 0x56, 0x78])]),
1718
sampleStr = '<?xml version="1.0" encoding="UTF-8"?>\n<俄语>данные</俄语>';
1819

1920
var fromCodePoint = String.fromCodePoint;
@@ -31,8 +32,8 @@ if (!fromCodePoint) {
3132
}
3233

3334
var allCharsStr = '';
34-
var allCharsLEBuf = new Buffer(0x10F800 * 4);
35-
var allCharsBEBuf = new Buffer(0x10F800 * 4);
35+
var allCharsLEBuf = Buffer.alloc(0x10F800 * 4);
36+
var allCharsBEBuf = Buffer.alloc(0x10F800 * 4);
3637
var skip = 0;
3738

3839
for (var i = 0; i <= 0x10F7FF; ++i) {
@@ -55,7 +56,7 @@ describe('UTF-32LE codec', function() {
5556
});
5657

5758
it('decodes uneven length buffers with no error', function() {
58-
assert.equal(iconv.decode(new Buffer([0x61, 0, 0, 0, 0]), 'UTF32-LE'), 'a');
59+
assert.equal(iconv.decode(Buffer.from([0x61, 0, 0, 0, 0]), 'UTF32-LE'), 'a');
5960
});
6061

6162
it('handles invalid surrogates gracefully', function() {
@@ -92,7 +93,7 @@ describe('UTF-32BE codec', function() {
9293
});
9394

9495
it('decodes uneven length buffers with no error', function() {
95-
assert.equal(iconv.decode(new Buffer([0, 0, 0, 0x61, 0]), 'UTF32-BE'), 'a');
96+
assert.equal(iconv.decode(Buffer.from([0, 0, 0, 0x61, 0]), 'UTF32-BE'), 'a');
9697
});
9798

9899
it('handles invalid surrogates gracefully', function() {

‎test/utf7-test.js

+44-43
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var assert = require('assert'),
2+
Buffer = require('safer-buffer').Buffer,
23
iconv = require(__dirname+'/../');
34

45
// These tests are mostly from https://github.com/kkaefer/utf7
@@ -30,59 +31,59 @@ describe("UTF-7 codec", function() {
3031

3132
it("decodes correctly", function() {
3233
// Examples from RFC 2152.
33-
assert.equal(iconv.decode(new Buffer('A+ImIDkQ-.'), 'utf-7'), 'A\u2262\u0391.');
34-
assert.equal(iconv.decode(new Buffer('A+ImIDkQ.'), 'utf-7'), 'A\u2262\u0391.');
34+
assert.equal(iconv.decode(Buffer.from('A+ImIDkQ-.'), 'utf-7'), 'A\u2262\u0391.');
35+
assert.equal(iconv.decode(Buffer.from('A+ImIDkQ.'), 'utf-7'), 'A\u2262\u0391.');
3536

36-
assert.equal(iconv.decode(new Buffer('+ZeVnLIqe-'), 'utf-7'), '\u65E5\u672C\u8A9E');
37-
assert.equal(iconv.decode(new Buffer('+ZeVnLIqe'), 'utf-7'), '\u65E5\u672C\u8A9E');
37+
assert.equal(iconv.decode(Buffer.from('+ZeVnLIqe-'), 'utf-7'), '\u65E5\u672C\u8A9E');
38+
assert.equal(iconv.decode(Buffer.from('+ZeVnLIqe'), 'utf-7'), '\u65E5\u672C\u8A9E');
3839

39-
assert.equal(iconv.decode(new Buffer('Hi Mom -+Jjo--!'), 'utf-7'), 'Hi Mom -\u263A-!');
40-
assert.equal(iconv.decode(new Buffer('Hi+ACA-Mom+ACA--+Jjo--+ACE-'), 'utf-7'), 'Hi Mom -\u263A-!');
41-
assert.equal(iconv.decode(new Buffer('Item 3 is +AKM-1.'), 'utf-7'), 'Item 3 is \u00A31.');
42-
assert.equal(iconv.decode(new Buffer('Item+ACA-3+ACA-is+ACAAow-1.'), 'utf-7'), 'Item 3 is \u00A31.');
40+
assert.equal(iconv.decode(Buffer.from('Hi Mom -+Jjo--!'), 'utf-7'), 'Hi Mom -\u263A-!');
41+
assert.equal(iconv.decode(Buffer.from('Hi+ACA-Mom+ACA--+Jjo--+ACE-'), 'utf-7'), 'Hi Mom -\u263A-!');
42+
assert.equal(iconv.decode(Buffer.from('Item 3 is +AKM-1.'), 'utf-7'), 'Item 3 is \u00A31.');
43+
assert.equal(iconv.decode(Buffer.from('Item+ACA-3+ACA-is+ACAAow-1.'), 'utf-7'), 'Item 3 is \u00A31.');
4344

4445
// Custom examples that contain more than one mode shift.
45-
assert.equal(iconv.decode(new Buffer('Jyv+AOQ-skyl+AOQ-'), 'utf-7'), 'Jyv\u00E4skyl\u00E4');
46-
assert.equal(iconv.decode(new Buffer('Jyv+AOQ-skyl+AOQ'), 'utf-7'), 'Jyv\u00E4skyl\u00E4');
47-
assert.equal(iconv.decode(new Buffer('\'+T2BZfQ-\' hei+AN8-t "Hallo"'), 'utf-7'), '\'\u4F60\u597D\' heißt "Hallo"');
48-
assert.equal(iconv.decode(new Buffer('\'+T2BZfQ\' hei+AN8-t "Hallo"'), 'utf-7'), '\'\u4F60\u597D\' heißt "Hallo"');
49-
assert.equal(iconv.decode(new Buffer('\'+T2BZfQ-\'+ACA-hei+AN8-t+ACAAIg-Hallo+ACI-'), 'utf-7'), '\'\u4F60\u597D\' heißt "Hallo"');
50-
assert.equal(iconv.decode(new Buffer('\'+T2BZfQ-\'+ACA-hei+AN8-t+ACAAIg-Hallo+ACI'), 'utf-7'), '\'\u4F60\u597D\' heißt "Hallo"');
46+
assert.equal(iconv.decode(Buffer.from('Jyv+AOQ-skyl+AOQ-'), 'utf-7'), 'Jyv\u00E4skyl\u00E4');
47+
assert.equal(iconv.decode(Buffer.from('Jyv+AOQ-skyl+AOQ'), 'utf-7'), 'Jyv\u00E4skyl\u00E4');
48+
assert.equal(iconv.decode(Buffer.from('\'+T2BZfQ-\' hei+AN8-t "Hallo"'), 'utf-7'), '\'\u4F60\u597D\' heißt "Hallo"');
49+
assert.equal(iconv.decode(Buffer.from('\'+T2BZfQ\' hei+AN8-t "Hallo"'), 'utf-7'), '\'\u4F60\u597D\' heißt "Hallo"');
50+
assert.equal(iconv.decode(Buffer.from('\'+T2BZfQ-\'+ACA-hei+AN8-t+ACAAIg-Hallo+ACI-'), 'utf-7'), '\'\u4F60\u597D\' heißt "Hallo"');
51+
assert.equal(iconv.decode(Buffer.from('\'+T2BZfQ-\'+ACA-hei+AN8-t+ACAAIg-Hallo+ACI'), 'utf-7'), '\'\u4F60\u597D\' heißt "Hallo"');
5152

5253
// The plus sign is represented by +-.
53-
assert.equal(iconv.decode(new Buffer('Hot +- Spicy +- Fruity'), 'utf-7'), 'Hot + Spicy + Fruity');
54-
assert.equal(iconv.decode(new Buffer('Hot+ACAAKwAg-Spicy+ACAAKwAg-Fruity'), 'utf-7'), 'Hot + Spicy + Fruity');
54+
assert.equal(iconv.decode(Buffer.from('Hot +- Spicy +- Fruity'), 'utf-7'), 'Hot + Spicy + Fruity');
55+
assert.equal(iconv.decode(Buffer.from('Hot+ACAAKwAg-Spicy+ACAAKwAg-Fruity'), 'utf-7'), 'Hot + Spicy + Fruity');
5556

5657
// Slashes in the beginning.
57-
assert.equal(iconv.decode(new Buffer('+///typh2VDIf7Q-'), 'utf-7'), '\uffff\uedca\u9876\u5432\u1fed');
58-
assert.equal(iconv.decode(new Buffer('+///typh2VDIf7Q'), 'utf-7'), '\uffff\uedca\u9876\u5432\u1fed');
58+
assert.equal(iconv.decode(Buffer.from('+///typh2VDIf7Q-'), 'utf-7'), '\uffff\uedca\u9876\u5432\u1fed');
59+
assert.equal(iconv.decode(Buffer.from('+///typh2VDIf7Q'), 'utf-7'), '\uffff\uedca\u9876\u5432\u1fed');
5960

6061
// + sign around non-ASCII chars
61-
assert.equal(iconv.decode(new Buffer('+AOQ-+-+AOQ-+-+AOQ-'), 'utf-7'), '\u00E4+\u00E4+\u00E4');
62-
//assert.equal(iconv.decode(new Buffer('+AOQ++AOQ+-+AOQ'), 'utf-7'), '\u00E4+\u00E4+\u00E4');
63-
assert.equal(iconv.decode(new Buffer('+AOQAKwDkACsA5A-'), 'utf-7'), '\u00E4+\u00E4+\u00E4');
64-
assert.equal(iconv.decode(new Buffer('+AOQAKwDkACsA5A'), 'utf-7'), '\u00E4+\u00E4+\u00E4');
62+
assert.equal(iconv.decode(Buffer.from('+AOQ-+-+AOQ-+-+AOQ-'), 'utf-7'), '\u00E4+\u00E4+\u00E4');
63+
//assert.equal(iconv.decode(Buffer.from('+AOQ++AOQ+-+AOQ'), 'utf-7'), '\u00E4+\u00E4+\u00E4');
64+
assert.equal(iconv.decode(Buffer.from('+AOQAKwDkACsA5A-'), 'utf-7'), '\u00E4+\u00E4+\u00E4');
65+
assert.equal(iconv.decode(Buffer.from('+AOQAKwDkACsA5A'), 'utf-7'), '\u00E4+\u00E4+\u00E4');
6566

6667

6768
// Tests from https://gist.github.com/peteroupc/08c5ecc8131a76062ffe
6869

69-
assert.equal(iconv.decode(new Buffer("\r\n\t '!\"#'(),$-%@[]^&=<>;*_`{}./:|?"), 'utf-7'), "\r\n\t '!\"#'(),$-%@[]^&=<>;*_`{}./:|?");
70-
assert.equal(iconv.decode(new Buffer("x+--"), 'utf-7'), "x+-");
71-
assert.equal(iconv.decode(new Buffer("x+-y"), 'utf-7'), "x+y");
70+
assert.equal(iconv.decode(Buffer.from("\r\n\t '!\"#'(),$-%@[]^&=<>;*_`{}./:|?"), 'utf-7'), "\r\n\t '!\"#'(),$-%@[]^&=<>;*_`{}./:|?");
71+
assert.equal(iconv.decode(Buffer.from("x+--"), 'utf-7'), "x+-");
72+
assert.equal(iconv.decode(Buffer.from("x+-y"), 'utf-7'), "x+y");
7273

7374
// UTF-16 code unit
74-
assert.equal(iconv.decode(new Buffer("+DEE?"), 'utf-7'), "\u0c41?");
75-
assert.equal(iconv.decode(new Buffer("+DEE"), 'utf-7'), "\u0c41");
75+
assert.equal(iconv.decode(Buffer.from("+DEE?"), 'utf-7'), "\u0c41?");
76+
assert.equal(iconv.decode(Buffer.from("+DEE"), 'utf-7'), "\u0c41");
7677

7778
// Surrogate pair
78-
assert.equal(iconv.decode(new Buffer("+2ADcAA?"), 'utf-7'), "\ud800\udc00?");
79-
assert.equal(iconv.decode(new Buffer("+2ADcAA"), 'utf-7'), "\ud800\udc00");
79+
assert.equal(iconv.decode(Buffer.from("+2ADcAA?"), 'utf-7'), "\ud800\udc00?");
80+
assert.equal(iconv.decode(Buffer.from("+2ADcAA"), 'utf-7'), "\ud800\udc00");
8081

8182
// Two UTF-16 code units
82-
assert.equal(iconv.decode(new Buffer("+AMAA4A?"), 'utf-7'), "\u00c0\u00e0?");
83-
assert.equal(iconv.decode(new Buffer("+AMAA4A"), 'utf-7'), "\u00c0\u00e0");
84-
assert.equal(iconv.decode(new Buffer("+AMAA4A-Next"), 'utf-7'), "\u00c0\u00e0Next");
85-
assert.equal(iconv.decode(new Buffer("+AMAA4A!Next"), 'utf-7'), "\u00c0\u00e0!Next");
83+
assert.equal(iconv.decode(Buffer.from("+AMAA4A?"), 'utf-7'), "\u00c0\u00e0?");
84+
assert.equal(iconv.decode(Buffer.from("+AMAA4A"), 'utf-7'), "\u00c0\u00e0");
85+
assert.equal(iconv.decode(Buffer.from("+AMAA4A-Next"), 'utf-7'), "\u00c0\u00e0Next");
86+
assert.equal(iconv.decode(Buffer.from("+AMAA4A!Next"), 'utf-7'), "\u00c0\u00e0!Next");
8687

8788
});
8889
});
@@ -111,22 +112,22 @@ describe("UTF-7-IMAP codec", function() {
111112

112113
it("decodes correctly", function() {
113114
// Examples from RFC 2152.
114-
assert.equal(iconv.decode(new Buffer('A&ImIDkQ-.'), 'utf-7-imap'), 'A\u2262\u0391.');
115-
assert.equal(iconv.decode(new Buffer('&ZeVnLIqe-'), 'utf-7-imap'), '\u65E5\u672C\u8A9E');
116-
assert.equal(iconv.decode(new Buffer('Hi Mom -&Jjo--!'), 'utf-7-imap'), 'Hi Mom -\u263A-!');
117-
assert.equal(iconv.decode(new Buffer('Item 3 is &AKM-1.'), 'utf-7-imap'), 'Item 3 is \u00A31.');
115+
assert.equal(iconv.decode(Buffer.from('A&ImIDkQ-.'), 'utf-7-imap'), 'A\u2262\u0391.');
116+
assert.equal(iconv.decode(Buffer.from('&ZeVnLIqe-'), 'utf-7-imap'), '\u65E5\u672C\u8A9E');
117+
assert.equal(iconv.decode(Buffer.from('Hi Mom -&Jjo--!'), 'utf-7-imap'), 'Hi Mom -\u263A-!');
118+
assert.equal(iconv.decode(Buffer.from('Item 3 is &AKM-1.'), 'utf-7-imap'), 'Item 3 is \u00A31.');
118119

119120
// Custom examples that contain more than one mode shift.
120-
assert.equal(iconv.decode(new Buffer('Jyv&AOQ-skyl&AOQ-'), 'utf-7-imap'), 'Jyv\u00E4skyl\u00E4');
121-
assert.equal(iconv.decode(new Buffer('\'&T2BZfQ-\' hei&AN8-t "Hallo"'), 'utf-7-imap'), '\'\u4F60\u597D\' heißt "Hallo"');
121+
assert.equal(iconv.decode(Buffer.from('Jyv&AOQ-skyl&AOQ-'), 'utf-7-imap'), 'Jyv\u00E4skyl\u00E4');
122+
assert.equal(iconv.decode(Buffer.from('\'&T2BZfQ-\' hei&AN8-t "Hallo"'), 'utf-7-imap'), '\'\u4F60\u597D\' heißt "Hallo"');
122123

123124
// The ampersand sign is represented by &-.
124-
assert.equal(iconv.decode(new Buffer('Hot &- Spicy &- Fruity'), 'utf-7-imap'), 'Hot & Spicy & Fruity');
125+
assert.equal(iconv.decode(Buffer.from('Hot &- Spicy &- Fruity'), 'utf-7-imap'), 'Hot & Spicy & Fruity');
125126

126127
// Slashes are converted to commas.
127-
assert.equal(iconv.decode(new Buffer('&,,,typh2VDIf7Q-'), 'utf-7-imap'), '\uffff\uedca\u9876\u5432\u1fed');
128+
assert.equal(iconv.decode(Buffer.from('&,,,typh2VDIf7Q-'), 'utf-7-imap'), '\uffff\uedca\u9876\u5432\u1fed');
128129

129130
// & sign around non-ASCII chars
130-
assert.equal(iconv.decode(new Buffer('&AOQ-&-&AOQ-&-&AOQ-'), 'utf-7-imap'), '\u00E4&\u00E4&\u00E4');
131+
assert.equal(iconv.decode(Buffer.from('&AOQ-&-&AOQ-&-&AOQ-'), 'utf-7-imap'), '\u00E4&\u00E4&\u00E4');
131132
});
132-
});
133+
});

0 commit comments

Comments
 (0)
Please sign in to comment.