encoding-sniffer
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.
Features
- Support for streams
- Support for XML encoding types, including UTF-16 prefixes and
<?xml encoding="...">
- Allows decoding streams and buffers with a single function call
Installation
npm install encoding-sniffer
Usage
import { DecodeStream, getEncoding, decodeBuffer } from "encoding-sniffer";
const options = {
maxBytes: 1024,
userEncoding: undefined,
transportLayerEncodingLabel: undefined,
defaultEncoding: "windows-1252",
};
const decodeStream = new DecodeStream(options);
const encoding = getEncoding(buffer, options);
const decodedBuffer = decodeBuffer(buffer, options);
License
This project is licensed under the MIT License. See the LICENSE file
for more information.