杰斯克莱特
Python's Chardet (英语:https://github.com/chardet/chardet (中文(简体) )) (中文(简体) ).
许可证
LGPL 语言
如何使用
节点
npm install jschardet
var jschardet = require("jschardet")
// "àíàçã" in UTF-8
jschardet.detect("\xc3\xa0\xc3\xad\xc3\xa0\xc3\xa7\xc3\xa3")
// { encoding: "UTF-8", confidence: 0.9690625 }
// "次常用國字標準字體表" in Big5
jschardet.detect("\xa6\xb8\xb1\x60\xa5\xce\xb0\xea\xa6\x72\xbc\xd0\xb7\xc7\xa6\x72\xc5\xe9\xaa\xed")
// { encoding: "Big5", confidence: 0.99 }
// Martin Kühl
// jschardet.detectAll("\x3c\x73\x74\x72\x69\x6e\x67\x3e\x4d\x61\x72\x74\x69\x6e\x20\x4b\xfc\x68\x6c\x3c\x2f\x73\x74\x72\x69\x6e\x67\x3e")
// [
// {encoding: "windows-1252", confidence: 0.95},
// {encoding: "ISO-8859-2", confidence: 0.8796300205763055},
// {encoding: "SHIFT_JIS", confidence: 0.01}
// ]
浏览器
复制并包含 jschardet.min.js (中文(简体) ) 在您的网页上.
该图书馆也可用于 (简体中文) 时间 https://cdnjs.cloudflare.com/ajax/libs/jschardet/1.4.1/jschardet.min.js
选项
// See all information related to the confidence levels of each encoding.
// This is useful to see why you're not getting the expected encoding.
jschardet.enableDebug();
// Default minimum accepted confidence level is 0.20 but sometimes this is not
// enough, specially when dealing with files mostly with numbers.
// To change this to 0 to always get something or any other value that can
// work for you.
jschardet.detect(str, { minimumThreshold: 0 });
// Lock down which encodings to detect, can be useful in situations jschardet
// is giving a higher probability to encodings that you never use.
jschardet.detect(str, { detectEncodings: ["UTF-8", "windows-1252"] });
支持的字符集
- Big5,GB2312/GB18030,EUC-TW,HZ-GB-2312,和ISO-2022-CN (传统和简化中文)
- EUC-JP, SHIFT JIS,和ISO-2022-JP (日语)
- EUC-KR和ISO-2022-KR (韩语)
- KOI8-R, MacCyrilic, IBM855, IBM866, ISO-8859-5和窗口-1251 (俄语)
- ISO-8859-2和窗口-1250 (匈牙利语)
- ISO-8859-5和窗口-1251(保加利亚文)
- 窗口-1252
- ISO-8859-7和窗口-1253 (希腊语)
- ISO-8859-8和窗口-1255(视觉和逻辑希伯来语)
- TIS-620 (泰语)
- UTF-32 BE, LE, 3412 命令,或 2143 命令(带有BOM)
- UTF-16 BE 或 LE (带有 BOM) 设备
- UTF-8(有或无BOM)
- ASC 二届理事会
技术信息
我无法建立测试 正确检测:
- ISO-2022-CN 标准
- 窗口-1250, 匈牙利语
- 保加利亚语窗口-1251
- 窗口-1253,希腊语
- 欧洲化学品理事会
发展
使用 npm run dist 以更新分发文件。 他们有在 https://github.com/aadsm/jschardet/tree/master/dist 页面存档备份,存于互联网档案馆。 。 。 .
作者数
由Python至JavaScript由安东尼奥·阿丰索(英语:António Afonso (python))出港https://github.com/aadsm/jschardet 页面存档备份,存于互联网档案馆(中文(简体) )
由 Markus Ast 转换成 npm 包(https://github.com/brainafk (英语)(中文(简体) )
