Socket
Socket
Sign inDemoInstall

iconv-lite

Package Overview
Dependencies
1
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.19 to 0.4.20

5

Changelog.md
# 0.4.20 / 2018-04-06
* Updated `new Buffer()` usages with recommended replacements as it's being deprecated in Node v10 (#176, #178 by @ChALkeR)
# 0.4.19 / 2017-09-09

@@ -3,0 +8,0 @@

12

encodings/dbcs-codec.js
"use strict";
var Buffer = require("buffer").Buffer;
var Buffer = require("safer-buffer").Buffer;

@@ -284,3 +284,3 @@ // Multibyte codec. In this scheme, a character is represented by 1 or more bytes.

DBCSEncoder.prototype.write = function(str) {
var newBuf = new Buffer(str.length * (this.gb18030 ? 4 : 3)),
var newBuf = Buffer.alloc(str.length * (this.gb18030 ? 4 : 3)),
leadSurrogate = this.leadSurrogate,

@@ -408,3 +408,3 @@ seqObj = this.seqObj, nextChar = -1,

var newBuf = new Buffer(10), j = 0;
var newBuf = Buffer.alloc(10), j = 0;

@@ -445,3 +445,3 @@ if (this.seqObj) { // We're in the sequence.

this.nodeIdx = 0;
this.prevBuf = new Buffer(0);
this.prevBuf = Buffer.alloc(0);

@@ -456,3 +456,3 @@ // Static data

DBCSDecoder.prototype.write = function(buf) {
var newBuf = new Buffer(buf.length*2),
var newBuf = Buffer.alloc(buf.length*2),
nodeIdx = this.nodeIdx,

@@ -534,3 +534,3 @@ prevBuf = this.prevBuf, prevBufOffset = this.prevBuf.length,

// Parse remaining as usual.
this.prevBuf = new Buffer(0);
this.prevBuf = Buffer.alloc(0);
this.nodeIdx = 0;

@@ -537,0 +537,0 @@ if (buf.length > 0)

"use strict";
var Buffer = require("buffer").Buffer;
var Buffer = require("safer-buffer").Buffer;

@@ -36,3 +36,3 @@ // Export Node.js internal encodings.

// Add decoder for versions of Node not supporting CESU-8
if (new Buffer('eda0bdedb2a9', 'hex').toString() !== '💩') {
if (Buffer.from('eda0bdedb2a9', 'hex').toString() !== '💩') {
this.decoder = InternalDecoderCesu8;

@@ -71,3 +71,3 @@ this.defaultCharUnicode = iconv.defaultCharUnicode;

InternalEncoder.prototype.write = function(str) {
return new Buffer(str, this.enc);
return Buffer.from(str, this.enc);
}

@@ -92,7 +92,7 @@

return new Buffer(str, "base64");
return Buffer.from(str, "base64");
}
InternalEncoderBase64.prototype.end = function() {
return new Buffer(this.prevStr, "base64");
return Buffer.from(this.prevStr, "base64");
}

@@ -108,3 +108,3 @@

InternalEncoderCesu8.prototype.write = function(str) {
var buf = new Buffer(str.length * 3), bufIdx = 0;
var buf = Buffer.alloc(str.length * 3), bufIdx = 0;
for (var i = 0; i < str.length; i++) {

@@ -111,0 +111,0 @@ var charCode = str.charCodeAt(i);

"use strict";
var Buffer = require("buffer").Buffer;
var Buffer = require("safer-buffer").Buffer;

@@ -23,7 +23,6 @@ // Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that

this.decodeBuf = new Buffer(codecOptions.chars, 'ucs2');
this.decodeBuf = new Buffer.from(codecOptions.chars, 'ucs2');
// Encoding buffer.
var encodeBuf = new Buffer(65536);
encodeBuf.fill(iconv.defaultCharSingleByte.charCodeAt(0));
var encodeBuf = new Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));

@@ -45,3 +44,3 @@ for (var i = 0; i < codecOptions.chars.length; i++)

SBCSEncoder.prototype.write = function(str) {
var buf = new Buffer(str.length);
var buf = Buffer.alloc(str.length);
for (var i = 0; i < str.length; i++)

@@ -64,3 +63,3 @@ buf[i] = this.encodeBuf[str.charCodeAt(i)];

var decodeBuf = this.decodeBuf;
var newBuf = new Buffer(buf.length*2);
var newBuf = Buffer.alloc(buf.length*2);
var idx1 = 0, idx2 = 0;

@@ -67,0 +66,0 @@ for (var i = 0; i < buf.length; i++) {

"use strict";
var Buffer = require("buffer").Buffer;
var Buffer = require("safer-buffer").Buffer;

@@ -23,3 +23,3 @@ // Note: UTF16-LE (or UCS2) codec is Node.js native. See encodings/internal.js

Utf16BEEncoder.prototype.write = function(str) {
var buf = new Buffer(str, 'ucs2');
var buf = Buffer.from(str, 'ucs2');
for (var i = 0; i < buf.length; i += 2) {

@@ -45,3 +45,3 @@ var tmp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = tmp;

var buf2 = new Buffer(buf.length + 1),
var buf2 = Buffer.alloc(buf.length + 1),
i = 0, j = 0;

@@ -48,0 +48,0 @@

"use strict";
var Buffer = require("buffer").Buffer;
var Buffer = require("safer-buffer").Buffer;

@@ -29,3 +29,3 @@ // UTF-7 codec, according to https://tools.ietf.org/html/rfc2152

// Non-direct chars are encoded as "+<base64>-"; single "+" char is encoded as "+-".
return new Buffer(str.replace(nonDirectChars, function(chunk) {
return Buffer.from(str.replace(nonDirectChars, function(chunk) {
return "+" + (chunk === '+' ? '' :

@@ -79,3 +79,3 @@ this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, ''))

var b64str = base64Accum + buf.slice(lastI, i).toString();
res += this.iconv.decode(new Buffer(b64str, 'base64'), "utf16-be");
res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
}

@@ -102,3 +102,3 @@

res += this.iconv.decode(new Buffer(b64str, 'base64'), "utf16-be");
res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
}

@@ -115,3 +115,3 @@

if (this.inBase64 && this.base64Accum.length > 0)
res = this.iconv.decode(new Buffer(this.base64Accum, 'base64'), "utf16-be");
res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), "utf16-be");

@@ -151,3 +151,3 @@ this.inBase64 = false;

this.inBase64 = false;
this.base64Accum = new Buffer(6);
this.base64Accum = Buffer.alloc(6);
this.base64AccumIdx = 0;

@@ -160,3 +160,3 @@ }

base64AccumIdx = this.base64AccumIdx,
buf = new Buffer(str.length*5 + 10), bufIdx = 0;
buf = Buffer.alloc(str.length*5 + 10), bufIdx = 0;

@@ -207,3 +207,3 @@ for (var i = 0; i < str.length; i++) {

Utf7IMAPEncoder.prototype.end = function() {
var buf = new Buffer(10), bufIdx = 0;
var buf = Buffer.alloc(10), bufIdx = 0;
if (this.inBase64) {

@@ -256,3 +256,3 @@ if (this.base64AccumIdx > 0) {

var b64str = base64Accum + buf.slice(lastI, i).toString().replace(/,/g, '/');
res += this.iconv.decode(new Buffer(b64str, 'base64'), "utf16-be");
res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
}

@@ -279,3 +279,3 @@

res += this.iconv.decode(new Buffer(b64str, 'base64'), "utf16-be");
res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
}

@@ -292,3 +292,3 @@

if (this.inBase64 && this.base64Accum.length > 0)
res = this.iconv.decode(new Buffer(this.base64Accum, 'base64'), "utf16-be");
res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), "utf16-be");

@@ -295,0 +295,0 @@ this.inBase64 = false;

"use strict";
var Buffer = require("buffer").Buffer;
// Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer

@@ -11,2 +12,3 @@ // == Extend Node primitives to use iconv-lite =================================

// Uint8Array and we cannot patch key functions since then.
// Note: this does use older Buffer API on a purpose
iconv.supportsNodeEncodingsExtension = !(new Buffer(0) instanceof Uint8Array);

@@ -13,0 +15,0 @@

@@ -5,3 +5,3 @@ "use strict";

// Solution would be installing npm modules "buffer" and "stream" explicitly.
var Buffer = require("buffer").Buffer;
var Buffer = require("safer-buffer").Buffer;

@@ -38,3 +38,3 @@ var bomHandling = require("./bom-handling"),

buf = new Buffer("" + (buf || ""), "binary"); // Ensure buffer.
buf = Buffer.from("" + (buf || ""), "binary"); // Ensure buffer.
}

@@ -41,0 +41,0 @@

{
"name": "iconv-lite",
"description": "Convert character encodings in pure javascript.",
"version": "0.4.19",
"version": "0.4.20",
"license": "MIT",

@@ -48,4 +48,4 @@ "keywords": [

"devDependencies": {
"mocha": "*",
"request": "*",
"mocha": "^3.1.0",
"request": "~2.81.0",
"unorm": "*",

@@ -57,3 +57,6 @@ "errto": "*",

"iconv": "*"
},
"dependencies": {
"safer-buffer": "^2.1.0"
}
}

@@ -23,3 +23,3 @@ ## Pure JS character encoding conversion [![Build Status](https://travis-ci.org/ashtuchkin/iconv-lite.svg?branch=master)](https://travis-ci.org/ashtuchkin/iconv-lite)

// Convert from an encoded buffer to js string.
str = iconv.decode(new Buffer([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251');
str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251');

@@ -26,0 +26,0 @@ // Convert from js string to an encoded buffer.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc