npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lazy-iconv/html-encoding-sniffer

v1.0.15

Published

Normalize HTML encoding by sniffing and decoding with proper encoding / 透過偵測和解碼正確編碼來標準化 HTML 編碼

Readme

@lazy-iconv/html-encoding-sniffer

Normalize HTML encoding by sniffing and decoding with proper encoding. 透過偵測和解碼正確編碼來標準化 HTML 編碼。

This module is inspired by JSDOM's html-encoding-sniffer implementation. 此模組靈感來自 JSDOM 的 html-encoding-sniffer 實作

Features / 功能

  • Auto-detect HTML encoding from Buffer/ArrayBuffer / 從 Buffer/ArrayBuffer 自動偵測 HTML 編碼
  • Decode HTML with proper encoding / 使用正確編碼解碼 HTML
  • Support transport layer encoding label / 支援傳輸層編碼標籤
  • Support string, Buffer, and ArrayBuffer input / 支援字串、Buffer 和 ArrayBuffer 輸入

Install / 安裝

yarn add @lazy-iconv/html-encoding-sniffer
yarn-tool add @lazy-iconv/html-encoding-sniffer
yt add @lazy-iconv/html-encoding-sniffer
pnpm add @lazy-iconv/html-encoding-sniffer
npm install @lazy-iconv/html-encoding-sniffer

Quick Start / 快速開始

import { normalizeHTML } from '@lazy-iconv/html-encoding-sniffer';

// From Buffer / 從 Buffer
const buffer = Buffer.from('<html>...', 'utf-8');
const result = normalizeHTML(buffer);
console.log(result.html);     // Decoded HTML string
console.log(result.encoding); // Detected encoding: 'UTF-8'

// From ArrayBuffer / 從 ArrayBuffer
const arrayBuffer = new ArrayBuffer(100);
const result2 = normalizeHTML(arrayBuffer);

// From string / 從字串
const result3 = normalizeHTML('<html>...</html>');

// With transport layer encoding / 使用傳輸層編碼
const result4 = normalizeHTML(buffer, 'text/html; charset=utf-8');

API

normalizeHTML(html, transportLayerEncodingLabel?)

Normalizes HTML input by detecting and decoding with proper encoding. 透過偵測和解碼正確編碼來標準化 HTML 輸入。

Parameters / 參數

  • html: string | Buffer | ArrayBuffer - The HTML input / HTML 輸入
  • transportLayerEncodingLabel?: string - Optional transport layer encoding hint / 可選的傳輸層編碼提示

Returns / 返回

interface INormalizeHTML {
  html: string;      // Normalized HTML string / 標準化後的 HTML 字串
  encoding: string;  // Detected encoding / 偵測到的編碼
}

Dependencies / 依賴