Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
encoding-sniffer
Advanced tools
Implementation of the HTML encoding sniffer algo, with stream support
An implementation of the HTML encoding sniffer algo, with stream support.
This module wraps around iconv-lite to make decoding buffers and streams incredibly easy.
<?xml encoding="...">
npm install encoding-sniffer
import { DecodeStream, getEncoding, decodeBuffer } from "encoding-sniffer";
/**
* All functions accept an optional options object.
*
* Available options are (with default values):
*/
const options = {
/**
* The maximum number of bytes to sniff. Defaults to `1024`.
*/
maxBytes: 1024,
/**
* The encoding specified by the user. If set, this will only be overridden
* by a Byte Order Mark (BOM).
*/
userEncoding: undefined,
/**
* The encoding specified by the transport layer. If set, this will only be
* overridden by a Byte Order Mark (BOM) or the user encoding.
*/
transportLayerEncodingLabel: undefined,
/**
* The default encoding to use, if no encoding can be detected.
*
* Defaults to `"windows-1252"`.
*/
defaultEncoding: "windows-1252",
};
// Use the `DecodeStream` transform stream to automatically decode
// the contents of a stream as they are read
const decodeStream = new DecodeStream(options);
// Or, use the `getEncoding` function to detect the encoding of a buffer
const encoding = getEncoding(buffer, options);
// Use the `decodeBuffer` function to decode the contents of a buffer
const decodedBuffer = decodeBuffer(buffer, options);
This project is licensed under the MIT License. See the LICENSE file for more information.
FAQs
Implementation of the HTML encoding sniffer algo, with stream support
The npm package encoding-sniffer receives a total of 2,000,048 weekly downloads. As such, encoding-sniffer popularity was classified as popular.
We found that encoding-sniffer demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.