跳转到主要内容

Python 3的通用编码检测器

项目描述

Chardet:通用字符编码检测器

Build status https://img.shields.io/coveralls/chardet/chardet/stable.svg Latest version on PyPI License
检测
  • ASCII, UTF-8, UTF-16(2种变体),UTF-32(4种变体)

  • Big5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN(繁体中文和简体中文)

  • EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP(日语)

  • EUC-KR, ISO-2022-KR, Johab(韩语)

  • KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, windows-1251(西里尔文)

  • ISO-8859-5, windows-1251(保加利亚语)

  • ISO-8859-1, windows-1252, MacRoman(西欧语言)

  • ISO-8859-7, windows-1253(希腊语)

  • ISO-8859-8, windows-1255(视觉和逻辑希伯来语)

  • TIS-620(泰语)

需要 Python 3.7+。

安装

PyPI 安装

pip install chardet

文档

对于用户,文档现在可在 https://chardet.readthedocs.io/ 找到。

命令行工具

chardet 附带一个命令行脚本,该脚本报告一个或多个文件的编码

% chardetect somefile someotherfile
somefile: windows-1252 with confidence 0.5
someotherfile: ascii with confidence 1.0

关于

这是 Mark Pilgrim 精美的原始 chardet 从 C 端口转换的延续,以及 Ian Cordascocharade Python 3 兼容分支。

维护者:

Dan Blanchard

由以下机构支持