# iconv-jschardet

> JavaScript 字符編碼轉換與自動檢測工具 (支援 iconv-lite, jschardet) / Character encoding conversion and auto-detection tool in JavaScript (supports iconv-lite, jschardet)

Latest version **2.0.36** (published 2026-03-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install iconv-jschardet
pnpm add iconv-jschardet
yarn add iconv-jschardet
bun add iconv-jschardet
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.36 |
| Published | 2026-03-02 |
| First published | 2018-01-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 104.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | big-5, big5, buffer, charset, chinese, conv, convert, create, decode, encode, encoding, euc-jp, extra, gb2312, gbk, iconv, iconv-lite, icu, jschardet, output, read, shift_jis, text, unicode, utf-8, character-encoding, auto-detection, buffer-conversion, text-encoding, encoding-detection, nodejs-encoding, typescript-encoding, encoding-utils, charset-detection, encoding-conversion |

## Links

- npm: https://www.npmjs.com/package/iconv-jschardet
- Repository: https://github.com/bluelovers/ws-iconv
- Homepage: https://github.com/bluelovers/ws-iconv/tree/master/packages/iconv-jschardet#readme
- Issues: https://github.com/bluelovers/ws-iconv/issues
- npm.io page: https://npm.io/package/iconv-jschardet

## Dependencies (5)

- [tslib](https://npm.io/package/tslib.md) ^2
- [env-bool](https://npm.io/package/env-bool.md) ^2.0.1
- [jschardet](https://npm.io/package/jschardet.md) ^3.1.3
- [iconv-lite](https://npm.io/package/iconv-lite.md) ^0.6.3
- [debug-color2](https://npm.io/package/debug-color2.md) ^1

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 2.0.36 (latest) — 2026-03-02
- 2.0.35 — 2026-03-01
- 2.0.33 — 2024-08-29
- 2.0.32 — 2022-10-02
- 2.0.31 — 2022-09-29
- 2.0.29 — 2022-09-28
- 2.0.28 — 2022-08-11
- 2.0.26 — 2022-05-11
- 2.0.24 — 2021-12-29
- 2.0.21 — 2021-08-30
- 2.0.20 — 2021-08-20
- 2.0.19 — 2021-08-20
- 2.0.18 — 2021-08-13
- 2.0.17 — 2021-07-08
- 2.0.16 — 2021-06-16
- … 23 more at https://npm.io/package/iconv-jschardet/versions

## README

# iconv-jschardet

> JavaScript 字符編碼轉換與自動檢測工具 (支援 iconv-lite, jschardet) / Character encoding conversion and auto-detection tool in JavaScript (supports iconv-lite, jschardet)

## 安裝 / Installation

```bash
npm install iconv-jschardet
```

```bash
yarn add iconv-jschardet
```

```bash
pnpm add iconv-jschardet
```

## 功能特色 / Features

- ✅ **自動編碼檢測** - 使用 jschardet 自動識別文本編碼 / Auto-detection of text encoding using jschardet
- ✅ **多編碼支援** - 支援 Big5、GBK、UTF-8、ASCII 等多種編碼 / Support for multiple encodings including Big5, GBK, UTF-8, ASCII
- ✅ **Buffer 轉換** - 提供靈活的 Buffer 轉換功能 / Flexible Buffer conversion capabilities
- ✅ **TypeScript 支援** - 完整的 TypeScript 類型定義 / Complete TypeScript type definitions
- ✅ **Node.js 相容** - 與 Node.js 原生 Buffer API 完全相容 / Fully compatible with Node.js native Buffer API

## 使用範例 / Usage Examples

### 基本匯入 / Basic Import

```ts
import * as iconv from 'iconv-jschardet';

// 或使用預設匯入 / Or use default import
import iconv from 'iconv-jschardet';
```

### BufferFrom - 多格式轉換 / BufferFrom - Multi-format Conversion

```js
const BIG5_HEX = 'a6b8b160a5ceb0eaa672bcd0b7c7a672c5e9aaed';

// 轉換為 UTF-8 Buffer / Convert to UTF-8 Buffer
iconv.BufferFrom(Buffer.from(BIG5_HEX, 'hex'), 'utf8')
iconv.BufferFrom(BIG5_HEX, 'utf8', 'hex')

// 轉換為 Big5 Buffer / Convert to Big5 Buffer
iconv.BufferFrom(Buffer.from(BIG5_HEX, 'hex'), 'big5')
iconv.BufferFrom(BIG5_HEX, 'big5', 'hex')
```

### 編碼檢測與轉換 / Encoding Detection and Conversion

```js
const BIG5_STR = "\xa6\xb8\xb1\x60\xa5\xce\xb0\xea\xa6\x72\xbc\xd0\xb7\xc7\xa6\x72\xc5\xe9\xaa\xed";
const BIG5_BUF = Buffer.from('a6b8b160a5ceb0eaa672bcd0b7c7a672c5e9aaed', 'hex');

const BIG5_UTF8_BUF = Buffer.from('e6 ac a1 e5 b8 b8 e7 94 a8 e5 9c 8b e5 ad 97 e6 a8 99 e6 ba 96 e5 ad 97 e9 ab 94 e8 a1 a8'.replace(/\s/g, ''), 'hex');
```

```ts
// 編碼檢測 / Encoding Detection
// 同等於 jschardet.detect
// Equivalent to jschardet.detect
iconv.detect(BIG5_STR);
iconv.detect(BIG5_BUF);

// 編碼轉換 / Encoding Conversion
// Big5 Buffer
iconv.encode(BIG5_STR, 'big5');
iconv.encode(BIG5_BUF, 'big5');

// UTF-8 Buffer
iconv.encode(BIG5_STR, 'utf8');
iconv.encode(BIG5_BUF, 'utf8');

// UTF-8 字串
iconv.decode(BIG5_STR);
iconv.decode(BIG5_BUF);
```

### 進階功能 / Advanced Features

```ts
// 停用解碼警告 / Disable decode warnings
iconv.skipDecodeWarning(bool: boolean = true)

// 停用編碼資料警告 / Disable codec data warnings
iconv.disableCodecDataWarn(bool: boolean = true)
```

## API 文件 / API Documentation

### 主要函數 / Main Functions

#### `detect(str, plus?: boolean): IDetectData`
自動檢測輸入內容的編碼格式
Automatically detect the encoding format of input content

#### `encode(str, to: vEncoding, from?: vEncoding, options?: IOptionsIconvLite): Buffer`
將輸入內容轉換為指定編碼的 Buffer
Convert input content to Buffer with specified encoding

#### `decode(str, from?: vEncoding): string`
將輸入內容解碼為字串
Decode input content to string

#### `BufferFrom(str, encoding?: vEncoding, from?: vEncoding, options?: IOptionsIconvLite): Buffer`
將多種格式的輸入轉換為 Buffer
Convert various input formats to Buffer

#### `skipDecodeWarning(bool?: boolean): boolean`
控制是否顯示解碼警告
Control whether to display decode warnings

#### `disableCodecDataWarn(bool?: boolean): boolean`
控制是否顯示編碼資料警告
Control whether to display codec data warnings

## 相關套件 / Related Packages

- [fs-iconv](https://www.npmjs.com/package/fs-iconv) - 檔案系統編碼處理 / File system encoding handling
- [iconv-lite](https://www.npmjs.com/package/iconv-lite) - 輕量級編碼轉換 / Lightweight encoding conversion
- [jschardet](https://www.npmjs.com/package/jschardet) - 編碼自動檢測 / Automatic encoding detection

## 貢獻 / Contributing

歡迎提交 Issue 和 Pull Request！

Welcome to submit Issues and Pull Requests!

## 授權 / License

ISC

---
_Source: https://npm.io/package/iconv-jschardet · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
