Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

legacy-encoding

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

legacy-encoding - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

6

encodings.js
'use strict';
module.exports = [
require('ibm866'),
require('iso-8859-10'),
require('iso-8859-13'),
require('iso-8859-14'),
require('iso-8859-15'),
require('iso-8859-16'),
require('iso-8859-2'),

@@ -19,3 +14,2 @@ require('iso-8859-3'),

require('koi8-r'),
require('koi8-u'),
require('macintosh'),

@@ -22,0 +16,0 @@ require('windows-1250'),

27

index.js
'use strict'
var encodings = require('./encodings.js').concat([
{
labels: ['utf-7'],
encode: require('utf7').encode,
decode: require('utf7').decode
}
]);
var iconv;
try {
iconv = require('iconv-lite');
} catch (ex) {
// missing optional dependency iconv-lite
}
var encodings = require('./encodings.js');
exports.labels = encodings.map(function (enc) {
return enc.labels;
}).reduce(function (acc, next) {
}).concat(iconv ? Object.keys(require('iconv-lite/encodings')) : []).reduce(function (acc, next) {
return acc.concat(next);

@@ -19,5 +20,8 @@ }, []).sort();

function decode(source, encoding, options) {
if (iconv && iconv.encodingExists(encoding)) {
return iconv.decode(source, encoding);
}
for (var i = 0; i < encodings.length; i++) {
if (encodings[i].labels.indexOf(encoding) !== -1) {
return encodings[i].decode(source, options);
return encodings[i].decode(source.toString('binary'), options);
}

@@ -29,5 +33,8 @@ }

function encode(source, encoding, options) {
if (iconv && iconv.encodingExists(encoding)) {
return iconv.encode(source, encoding);
}
for (var i = 0; i < encodings.length; i++) {
if (encodings[i].labels.indexOf(encoding) !== -1) {
return encodings[i].encode(source, options);
return new Buffer(encodings[i].encode(source, options), 'binary');
}

@@ -34,0 +41,0 @@ }

{
"name": "legacy-encoding",
"version": "1.2.0",
"version": "2.0.0",
"description": "Support as many legacy encodings as possible",

@@ -18,19 +18,196 @@ "files": [

"legacy-encoding",
"10000",
"10006",
"10007",
"10029",
"10079",
"10081",
"1046",
"1124",
"1125",
"1129",
"1133",
"1161",
"1162",
"1163",
"1250",
"1251",
"1252",
"1253",
"1254",
"1255",
"1256",
"1257",
"1258",
"20866",
"21866",
"28591",
"28592",
"28593",
"28594",
"28595",
"28596",
"28597",
"28598",
"28599",
"28600",
"28601",
"28603",
"28604",
"28605",
"28606",
"437",
"737",
"775",
"808",
"850",
"852",
"855",
"856",
"857",
"858",
"860",
"861",
"862",
"863",
"864",
"865",
"866",
"869",
"874",
"922",
"932",
"936",
"949",
"950",
"_dbcs",
"_internal",
"_sbcs",
"ansi_x3.4-1968",
"ansix3.4",
"ansix3.41968",
"ansix3.41986",
"arabic",
"arabic",
"arabic8",
"armscii8",
"ascii",
"ascii",
"ascii8bit",
"asmo-708",
"asmo708",
"base64",
"big5",
"big5hkscs",
"binary",
"celtic",
"celtic8",
"cesu8",
"chinese",
"cn",
"cnbig5",
"cp1046",
"cp1124",
"cp1125",
"cp1129",
"cp1133",
"cp1161",
"cp1162",
"cp1163",
"cp1250",
"cp1250",
"cp1251",
"cp1251",
"cp1252",
"cp1252",
"cp1253",
"cp1253",
"cp1254",
"cp1254",
"cp1255",
"cp1255",
"cp1256",
"cp1256",
"cp1257",
"cp1257",
"cp1258",
"cp1258",
"cp20866",
"cp21866",
"cp28591",
"cp28592",
"cp28593",
"cp28594",
"cp28595",
"cp28596",
"cp28597",
"cp28598",
"cp28599",
"cp28600",
"cp28601",
"cp28603",
"cp28604",
"cp28605",
"cp28606",
"cp367",
"cp437",
"cp737",
"cp775",
"cp808",
"cp819",
"cp819",
"cp850",
"cp852",
"cp855",
"cp856",
"cp857",
"cp858",
"cp860",
"cp861",
"cp862",
"cp863",
"cp864",
"cp865",
"cp866",
"cp869",
"cp874",
"cp922",
"cp932",
"cp936",
"cp949",
"cp950",
"cpgr",
"csascii",
"csbig5",
"cseuckr",
"csgb2312",
"cshproman8",
"csibm1046",
"csibm1124",
"csibm1125",
"csibm1129",
"csibm1133",
"csibm1161",
"csibm1162",
"csibm1163",
"csibm437",
"csibm737",
"csibm775",
"csibm850",
"csibm852",
"csibm855",
"csibm856",
"csibm857",
"csibm858",
"csibm860",
"csibm861",
"csibm862",
"csibm863",
"csibm864",
"csibm865",
"csibm866",
"csibm869",
"csibm922",
"csiso14jisc6220ro",
"csiso58gb231280",
"csiso88596e",

@@ -41,31 +218,97 @@ "csiso88596i",

"csisolatin1",
"csisolatin1",
"csisolatin2",
"csisolatin2",
"csisolatin3",
"csisolatin3",
"csisolatin4",
"csisolatin4",
"csisolatin5",
"csisolatin5",
"csisolatin6",
"csisolatin9",
"csisolatinarabic",
"csisolatinarabic",
"csisolatincyrillic",
"csisolatincyrillic",
"csisolatingreek",
"csisolatingreek",
"csisolatinhebrew",
"csisolatinhebrew",
"cskoi8r",
"cskoi8r",
"csksc56011987",
"csmacintosh",
"csmacintosh",
"cspc775baltic",
"cspc850multilingual",
"cspc862latinhebrew",
"cspc8codepage437",
"cspcp852",
"csshiftjis",
"cyrillic",
"cyrillic",
"dos-874",
"ecma-114",
"ecma-118",
"ecma114",
"ecma118",
"elot928",
"elot_928",
"euccn",
"eucjp",
"euckr",
"gb18030",
"gb198880",
"gb2312",
"gb23121980",
"gb231280",
"gbk",
"georgianacademy",
"georgianps",
"greek",
"greek",
"greek8",
"greek8",
"hebrew",
"hebrew",
"hebrew8",
"hex",
"hproman8",
"ibm1046",
"ibm1051",
"ibm1124",
"ibm1125",
"ibm1129",
"ibm1133",
"ibm1161",
"ibm1162",
"ibm1163",
"ibm1168",
"ibm367",
"ibm437",
"ibm737",
"ibm775",
"ibm808",
"ibm819",
"ibm819",
"ibm850",
"ibm852",
"ibm855",
"ibm856",
"ibm857",
"ibm858",
"ibm860",
"ibm861",
"ibm862",
"ibm863",
"ibm864",
"ibm865",
"ibm866",
"ibm869",
"ibm878",
"ibm922",
"iso-8859-1",
"iso-8859-10",
"iso-8859-11",
"iso-8859-13",
"iso-8859-14",
"iso-8859-15",
"iso-8859-16",
"iso-8859-2",

@@ -92,8 +335,8 @@ "iso-8859-3",

"iso-ir-148",
"iso-ir-157",
"iso646.irv",
"iso646cn",
"iso646jp",
"iso646us",
"iso8859-1",
"iso8859-10",
"iso8859-11",
"iso8859-13",
"iso8859-14",
"iso8859-15",

@@ -109,15 +352,27 @@ "iso8859-2",

"iso88591",
"iso88591",
"iso885910",
"iso885911",
"iso885911",
"iso885913",
"iso885914",
"iso885915",
"iso885915",
"iso885916",
"iso88592",
"iso88592",
"iso88593",
"iso88593",
"iso88594",
"iso88594",
"iso88595",
"iso88595",
"iso88596",
"iso88596",
"iso88597",
"iso88597",
"iso88598",
"iso88598",
"iso88599",
"iso88599",
"iso_8859-1",

@@ -142,28 +397,135 @@ "iso_8859-15",

"iso_8859-9:1989",
"isoceltic",
"isoir100",
"isoir101",
"isoir109",
"isoir110",
"isoir126",
"isoir127",
"isoir138",
"isoir14",
"isoir144",
"isoir148",
"isoir149",
"isoir157",
"isoir166",
"isoir179",
"isoir199",
"isoir203",
"isoir226",
"isoir57",
"isoir58",
"isoir6",
"jisc62201969ro",
"jp",
"koi",
"koi8",
"koi8-r",
"koi8-u",
"koi8_r",
"koi8r",
"koi8ru",
"koi8t",
"koi8u",
"korean",
"ksc5601",
"ksc56011987",
"ksc56011989",
"l1",
"l1",
"l10",
"l2",
"l2",
"l3",
"l3",
"l4",
"l4",
"l5",
"l5",
"l6",
"l7",
"l8",
"l9",
"l9",
"latin1",
"latin1",
"latin10",
"latin2",
"latin2",
"latin3",
"latin3",
"latin4",
"latin4",
"latin5",
"latin5",
"latin6",
"latin7",
"latin8",
"latin9",
"logical",
"mac",
"mac",
"maccenteuro",
"maccroatian",
"maccyrillic",
"macgreek",
"maciceland",
"macintosh",
"macintosh",
"macroman",
"macromania",
"macthai",
"macturkish",
"macukraine",
"msansi",
"msarab",
"mscyrl",
"msee",
"msgreek",
"mshebr",
"mskanji",
"msturk",
"pt154",
"r8",
"rk1048",
"roman8",
"shiftjis",
"sjis",
"strk10482002",
"sun_eu_greek",
"tcvn",
"tcvn5712",
"tcvn57121",
"thai",
"thai8",
"tis-620",
"tis620",
"tis620.25291",
"tis620.25330",
"tis6200",
"turkish",
"turkish8",
"ucs2",
"unicode11utf8",
"us",
"us-ascii",
"utf-7",
"usascii",
"utf16",
"utf16be",
"utf16le",
"utf7",
"utf7imap",
"utf8",
"viscii",
"visual",
"win1250",
"win1251",
"win1252",
"win1253",
"win1254",
"win1255",
"win1256",
"win1257",
"win1258",
"win874",
"winbaltrim",
"windows-1250",

@@ -178,3 +540,18 @@ "windows-1251",

"windows-1258",
"windows-31j",
"windows-874",
"windows1250",
"windows1251",
"windows1252",
"windows1253",
"windows1254",
"windows1255",
"windows1256",
"windows1257",
"windows1258",
"windows874",
"windows932",
"windows936",
"windows949",
"windows950",
"x-cp1250",

@@ -192,11 +569,11 @@ "x-cp1251",

"x-mac-ukrainian",
"x-sjis",
"xgbk",
"xroman8",
"xxbig5",
"browserify"
],
"dependencies": {
"ibm866": "^0.1.2",
"iso-8859-10": "^0.1.2",
"iso-8859-13": "^0.1.2",
"iso-8859-14": "^0.1.2",
"iconv-lite": "^0.4.4",
"iso-8859-15": "^0.1.2",
"iso-8859-16": "^0.1.2",
"iso-8859-2": "^0.1.2",

@@ -211,5 +588,3 @@ "iso-8859-3": "^0.1.2",

"koi8-r": "^0.1.2",
"koi8-u": "^0.1.2",
"macintosh": "^0.1.2",
"utf7": "^1.0.0",
"windows-1250": "^0.1.2",

@@ -216,0 +591,0 @@ "windows-1251": "^0.1.2",

@@ -16,3 +16,3 @@ # legacy-encoding

This function takes a plain text string (the `input` parameter) and encodes it acording the `encoding`. The return value is a 'byte string', i.e. a string of which each item represents an octet as per `encoding`.
This function takes a plain text string (the `input` parameter) and encodes it acording the `encoding`. The return value is a `Buffer`.

@@ -22,3 +22,3 @@ ```js

var encodedData = legacy.encode(text, encoding);
var buffer = legacy.encode(text, encoding);
```

@@ -31,3 +31,3 @@

var encodedData = legacy.encode(text, encoding, {
var buffer = legacy.encode(text, encoding, {
'mode': 'html'

@@ -39,13 +39,5 @@ });

To get a node.js buffer rather than a binary string, just call the `Buffer` constructor:
```js
var legacy = require('legacy-encoding');
var buf = new Buffer(legacy.encode(text, encoding), 'binary');
```
### `legacy.decode(input, encoding, options)`
This function takes a byte string (the `input` parameter) and decodes it according to `encoding`.
This function takes a `Buffer` (the `input` parameter) and decodes it according to `encoding`.

@@ -55,3 +47,3 @@ ```js

var text = legacy.decode(encodedData, encoding);
var text = legacy.decode(buffer, encoding);
```

@@ -62,3 +54,3 @@

```js
var text = windows1255.decode(encodedData, encoding, {
var text = windows1255.decode(buffer, encoding, {
'mode': 'fatal'

@@ -70,29 +62,198 @@ });

To usa a node.js buffer rather than a binary string, just call the `.toString('binary')` method:
```js
var legacy = require('legacy-encoding');
var text = legacy.decode(buf.toString('binary'), encoding);
```
## Supported Encodings
- 10000
- 10006
- 10007
- 10029
- 10079
- 10081
- 1046
- 1124
- 1125
- 1129
- 1133
- 1161
- 1162
- 1163
- 1250
- 1251
- 1252
- 1253
- 1254
- 1255
- 1256
- 1257
- 1258
- 20866
- 21866
- 28591
- 28592
- 28593
- 28594
- 28595
- 28596
- 28597
- 28598
- 28599
- 28600
- 28601
- 28603
- 28604
- 28605
- 28606
- 437
- 737
- 775
- 808
- 850
- 852
- 855
- 856
- 857
- 858
- 860
- 861
- 862
- 863
- 864
- 865
- 866
- 869
- 874
- 922
- 932
- 936
- 949
- 950
- _dbcs
- _internal
- _sbcs
- ansi_x3.4-1968
- ansix3.4
- ansix3.41968
- ansix3.41986
- arabic
- arabic
- arabic8
- armscii8
- ascii
- ascii
- ascii8bit
- asmo-708
- asmo708
- base64
- big5
- big5hkscs
- binary
- celtic
- celtic8
- cesu8
- chinese
- cn
- cnbig5
- cp1046
- cp1124
- cp1125
- cp1129
- cp1133
- cp1161
- cp1162
- cp1163
- cp1250
- cp1250
- cp1251
- cp1251
- cp1252
- cp1252
- cp1253
- cp1253
- cp1254
- cp1254
- cp1255
- cp1255
- cp1256
- cp1256
- cp1257
- cp1257
- cp1258
- cp1258
- cp20866
- cp21866
- cp28591
- cp28592
- cp28593
- cp28594
- cp28595
- cp28596
- cp28597
- cp28598
- cp28599
- cp28600
- cp28601
- cp28603
- cp28604
- cp28605
- cp28606
- cp367
- cp437
- cp737
- cp775
- cp808
- cp819
- cp819
- cp850
- cp852
- cp855
- cp856
- cp857
- cp858
- cp860
- cp861
- cp862
- cp863
- cp864
- cp865
- cp866
- cp869
- cp874
- cp922
- cp932
- cp936
- cp949
- cp950
- cpgr
- csascii
- csbig5
- cseuckr
- csgb2312
- cshproman8
- csibm1046
- csibm1124
- csibm1125
- csibm1129
- csibm1133
- csibm1161
- csibm1162
- csibm1163
- csibm437
- csibm737
- csibm775
- csibm850
- csibm852
- csibm855
- csibm856
- csibm857
- csibm858
- csibm860
- csibm861
- csibm862
- csibm863
- csibm864
- csibm865
- csibm866
- csibm869
- csibm922
- csiso14jisc6220ro
- csiso58gb231280
- csiso88596e

@@ -103,31 +264,97 @@ - csiso88596i

- csisolatin1
- csisolatin1
- csisolatin2
- csisolatin2
- csisolatin3
- csisolatin3
- csisolatin4
- csisolatin4
- csisolatin5
- csisolatin5
- csisolatin6
- csisolatin9
- csisolatinarabic
- csisolatinarabic
- csisolatincyrillic
- csisolatincyrillic
- csisolatingreek
- csisolatingreek
- csisolatinhebrew
- csisolatinhebrew
- cskoi8r
- cskoi8r
- csksc56011987
- csmacintosh
- csmacintosh
- cspc775baltic
- cspc850multilingual
- cspc862latinhebrew
- cspc8codepage437
- cspcp852
- csshiftjis
- cyrillic
- cyrillic
- dos-874
- ecma-114
- ecma-118
- ecma114
- ecma118
- elot928
- elot_928
- euccn
- eucjp
- euckr
- gb18030
- gb198880
- gb2312
- gb23121980
- gb231280
- gbk
- georgianacademy
- georgianps
- greek
- greek
- greek8
- greek8
- hebrew
- hebrew
- hebrew8
- hex
- hproman8
- ibm1046
- ibm1051
- ibm1124
- ibm1125
- ibm1129
- ibm1133
- ibm1161
- ibm1162
- ibm1163
- ibm1168
- ibm367
- ibm437
- ibm737
- ibm775
- ibm808
- ibm819
- ibm819
- ibm850
- ibm852
- ibm855
- ibm856
- ibm857
- ibm858
- ibm860
- ibm861
- ibm862
- ibm863
- ibm864
- ibm865
- ibm866
- ibm869
- ibm878
- ibm922
- iso-8859-1
- iso-8859-10
- iso-8859-11
- iso-8859-13
- iso-8859-14
- iso-8859-15
- iso-8859-16
- iso-8859-2

@@ -154,8 +381,8 @@ - iso-8859-3

- iso-ir-148
- iso-ir-157
- iso646.irv
- iso646cn
- iso646jp
- iso646us
- iso8859-1
- iso8859-10
- iso8859-11
- iso8859-13
- iso8859-14
- iso8859-15

@@ -171,15 +398,27 @@ - iso8859-2

- iso88591
- iso88591
- iso885910
- iso885911
- iso885911
- iso885913
- iso885914
- iso885915
- iso885915
- iso885916
- iso88592
- iso88592
- iso88593
- iso88593
- iso88594
- iso88594
- iso88595
- iso88595
- iso88596
- iso88596
- iso88597
- iso88597
- iso88598
- iso88598
- iso88599
- iso88599
- iso_8859-1

@@ -204,28 +443,135 @@ - iso_8859-15

- iso_8859-9:1989
- isoceltic
- isoir100
- isoir101
- isoir109
- isoir110
- isoir126
- isoir127
- isoir138
- isoir14
- isoir144
- isoir148
- isoir149
- isoir157
- isoir166
- isoir179
- isoir199
- isoir203
- isoir226
- isoir57
- isoir58
- isoir6
- jisc62201969ro
- jp
- koi
- koi8
- koi8-r
- koi8-u
- koi8_r
- koi8r
- koi8ru
- koi8t
- koi8u
- korean
- ksc5601
- ksc56011987
- ksc56011989
- l1
- l1
- l10
- l2
- l2
- l3
- l3
- l4
- l4
- l5
- l5
- l6
- l7
- l8
- l9
- l9
- latin1
- latin1
- latin10
- latin2
- latin2
- latin3
- latin3
- latin4
- latin4
- latin5
- latin5
- latin6
- latin7
- latin8
- latin9
- logical
- mac
- mac
- maccenteuro
- maccroatian
- maccyrillic
- macgreek
- maciceland
- macintosh
- macintosh
- macroman
- macromania
- macthai
- macturkish
- macukraine
- msansi
- msarab
- mscyrl
- msee
- msgreek
- mshebr
- mskanji
- msturk
- pt154
- r8
- rk1048
- roman8
- shiftjis
- sjis
- strk10482002
- sun_eu_greek
- tcvn
- tcvn5712
- tcvn57121
- thai
- thai8
- tis-620
- tis620
- tis620.25291
- tis620.25330
- tis6200
- turkish
- turkish8
- ucs2
- unicode11utf8
- us
- us-ascii
- utf-7
- usascii
- utf16
- utf16be
- utf16le
- utf7
- utf7imap
- utf8
- viscii
- visual
- win1250
- win1251
- win1252
- win1253
- win1254
- win1255
- win1256
- win1257
- win1258
- win874
- winbaltrim
- windows-1250

@@ -240,3 +586,18 @@ - windows-1251

- windows-1258
- windows-31j
- windows-874
- windows1250
- windows1251
- windows1252
- windows1253
- windows1254
- windows1255
- windows1256
- windows1257
- windows1258
- windows874
- windows932
- windows936
- windows949
- windows950
- x-cp1250

@@ -254,2 +615,6 @@ - x-cp1251

- x-mac-ukrainian
- x-sjis
- xgbk
- xroman8
- xxbig5

@@ -256,0 +621,0 @@ ## License

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc