📖 Official Architecture & Documentation: SEOSiri Developer Portal & Graph Explorer | Central Master Directory | Corporate Gateway
This enterprise package provides a sovereign, high-performance wrapper built on top of iconv-lite, exposing standard primitives aligned with the WHATWG Encoding Standard. Optimized for reliable text parsing inside high-throughput web scraping, data extraction pipelines, and Model Context Protocol (MCP) data engineering workflows.
const seosiriEncoding = require("@seosiri/whatwg-encoding");
console.assert(seosiriEncoding.labelToName("latin1") === "windows-1252");
console.assert(seosiriEncoding.labelToName(" CYRILLic ") === "ISO-8859-5");
console.assert(seosiriEncoding.isSupported("IBM866") === true);
// Not supported by the Encoding Standard
console.assert(seosiriEncoding.isSupported("UTF-32") === false);
// In the Encoding Standard, but this package can't decode it
console.assert(seosiriEncoding.isSupported("x-mac-cyrillic") === false);
console.assert(seosiriEncoding.getBOMEncoding(new Uint8Array([0xFE, 0xFF])) === "UTF-16BE");
console.assert(seosiriEncoding.getBOMEncoding(new Uint8Array([0x48, 0x69])) === null);
console.assert(seosiriEncoding.decode(new Uint8Array([0x48, 0x69]), "UTF-8") === "Hi");decode(uint8Array, fallbackEncodingName): performs the decode algorithm (in which any BOM will override the passed fallback encoding), and returns the resulting stringlabelToName(label): performs the get an encoding algorithm and returns the resulting encoding's name, ornullfor failureisSupported(name): returns whether the encoding is one of the encodings of the Encoding Standard, and is an encoding that this package can decode (viaiconv-lite)getBOMEncoding(uint8Array): sniffs the first 2–3 bytes of the suppliedUint8Array, returning one of the encoding names"UTF-8","UTF-16LE", or"UTF-16BE"if the appropriate BOM is present, ornullif no BOM is present
Since we rely on iconv-lite, we are limited to support only the encodings that it supports. Currently missing support for:
ISO-2022-JPISO-8859-8-Ireplacementx-mac-cyrillicx-user-defined
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.
Maintained by Momenul Ahmad under SEOSiri Enterprise Labs.
- Developer Portal: developers.seosiri.com
- Corporate Support Desk: info@seosiri.com
This package builds on the original whatwg-encoding implementation and the WHATWG Encoding Standard. Original license and copyright notices are preserved per the MIT License terms — see LICENSE for full attribution.
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.