Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
legacy-encoding
Advanced tools
Support as many legacy encodings as possible
npm install legacy-encoding
legacy.encode(input, encoding, options)
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
.
var legacy = require('legacy-encoding');
var encodedData = legacy.encode(text, encoding);
The optional options
object and its mode
property can be used to set the error mode. For encoding, the error mode can be 'fatal'
(the default) or 'html'
.
var legacy = require('legacy-encoding');
var encodedData = legacy.encode(text, encoding, {
'mode': 'html'
});
// If `text` contains a symbol that cannot be represented in the encoding,
// instead of throwing an error, it will return an HTML entity for the symbol.
To get a node.js buffer rather than a binary string, just call the Buffer
constructor:
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
.
var legacy = require('legacy-encoding');
var text = legacy.decode(encodedData, encoding);
The optional options
object and its mode
property can be used to set the error mode. For decoding, the error mode can be 'replacement'
(the default) or 'fatal'
.
var text = windows1255.decode(encodedData, encoding, {
'mode': 'fatal'
});
// If `encodedData` contains an invalid byte for the encoding,
// instead of replacing it with U+FFFD in the output, an error is thrown.
To usa a node.js buffer rather than a binary string, just call the .toString('binary')
method:
var legacy = require('legacy-encoding');
var text = legacy.decode(buf.toString('binary'), encoding);
MIT
FAQs
Support as many legacy encodings as possible
We found that legacy-encoding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.