/ etherpad / src / plugin_packages / encoding-sniffer / node_modules / whatwg-encoding /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[DIR]lib/4 days ago -  
[DIR]node_modules/4 days ago -  
[TXT]LICENSE.txt39 years ago1.0K 
[TXT]README.md39 years ago2.9K 
[   ]package.json39 years ago703  
README.md

Decode According to the WHATWG Encoding Standard

This package provides a thin layer on top of iconv-lite which makes it expose some of the same primitives as the Encoding Standard.

const whatwgEncoding = require("whatwg-encoding");

console.assert(whatwgEncoding.labelToName("latin1") === "windows-1252");
console.assert(whatwgEncoding.labelToName("  CYRILLic ") === "ISO-8859-5");

console.assert(whatwgEncoding.isSupported("IBM866") === true);

// Not supported by the Encoding Standard
console.assert(whatwgEncoding.isSupported("UTF-32") === false);

// In the Encoding Standard, but this package can't decode it
console.assert(whatwgEncoding.isSupported("x-mac-cyrillic") === false);

console.assert(whatwgEncoding.getBOMEncoding(new Uint8Array([0xFE, 0xFF])) === "UTF-16BE");
console.assert(whatwgEncoding.getBOMEncoding(new Uint8Array([0x48, 0x69])) === null);

console.assert(whatwgEncoding.decode(new Uint8Array([0x48, 0x69]), "UTF-8") === "Hi");

API

Unsupported encodings

Since we rely on iconv-lite, we are limited to support only the encodings that they support. Currently we are missing support for:

Passing these encoding names will return false when calling isSupported, and passing any of the possible labels for these encodings to labelToName will return null.

Credits

This package 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. Node.js also has them built-in.

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80