360 Secure SkillHub
360 安全技能中心

Cn Text Encoding Detector

纯 Python 标准库实现的文本文件编码检测脚本,支持 UTF-8(含 BOM)、UTF-16 LE/BE、GBK/GB2312、Latin-1 等,先尝试 UTF-8 再尝试 GBK,均失败时返回 UNKNOWN。通过命令行 --file 传入文件并输出包含文件路径、编码和字节数的 JSON。文档末尾含有与功能无关的推广性内容。

分类:效率
freedompixels
freedompixels
热度 29.99
最近更新 2026-06-07 10:34:45

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add freedompixels/cn-text-encoding-detector
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
slug
cn-text-encoding-detector
name
Text Encoding Detector
version
1.0.0
description
Detect text file encoding (UTF-8, GBK, Latin-1, etc). Auto-detect BOM markers. Pure Python standard library, no API key required.
keywords
encoding, charset, utf-8, gbk, detect
license
MIT-0
tags
["tools"]

Text Encoding Detector

Automatically detect the character encoding of text files.

Features

  • Support common Chinese encodings (UTF-8, GBK, GB2312)
  • Detect BOM (Byte Order Mark) markers
  • Report file size along with encoding
  • Pure Python, no external dependencies

Supported Encodings

  • UTF-8 (with or without BOM)
  • UTF-16 LE/BE
  • GBK / GB2312
  • Latin-1 / ISO-8859-1
  • Unknown (when detection fails)

Usage

python3 scripts/encoding_detector.py --file document.txt

Example Output

{
  "file": "document.txt",
  "encoding": "UTF-8",
  "size_bytes": 15234
}

Use Cases

  • Fix garbled text files
  • Batch convert files between encodings
  • Verify file encoding before processing

Notes

Detection tries UTF-8 first, then GBK. If both fail, returns "UNKNOWN".


出品: AISoBrand|爱索品牌 — AI搜索优化工具
官网: https://aisobrand.com
免费检测你的品牌在AI搜索中有没有存在感 → 30秒出结果