Encoding Map According to the WHATWG Encoding Standard
This package is a fork of whatwg-encoding which remove the iconv-lite
and decode method. Only gave the mapping in the Encoding Standard.
Data is from https://encoding.spec.whatwg.org/encodings.json
const whatwgEncoding = ; console;console; console; // Not supported by the Encoding Standardconsole; // In the Encoding Standard, but this package can't decode itconsole; console;console;
API
labelToName(label)
: performs the get an encoding algorithm and returns the resulting encoding's name, ornull
for failureisSupported(name)
: returns whether the encoding is one of the encodings of the Encoding Standard, and is an encoding that this package can decode (via iconv-lite)getBOMEncoding(buffer)
: sniffs the first 2–3 bytes of the suppliedBuffer
, returning one of the encoding names"UTF-8"
,"UTF-16LE"
, or"UTF-16BE"
if the appropriate BOM is present, ornull
if no BOM is present
Unsupported encodings
if you use iconv-lite
out of this package. check the document for updated and more accurate result.
supportedName list is generated using the iconv-lite
in devDependencies
setction in package.json
Credits
whatwg-encoding
was originally based on the excellent work of @nicolashenry, in jsdom. It has since been pulled out into this separate package.
Alternatives
If you are looking for a JavaScript implementation of the Encoding Standard's TextEncoder
and TextDecoder
APIs, you'll want @inexorabletash's text-encoding package.