360 Secure SkillHub
360 安全技能中心

Cn Text Encoding Detector

这款工具核心功能是自动检测文本文件编码,支持UTF-8、GBK等常见编码及BOM标记识别,同时返回文件大小;基于纯Python标准库,无外部依赖。典型场景包括修复乱码文本、批量转码前校验、文件处理前验证编码。输入为指定文本文件,输出是含文件名、编码、文件大小的JSON结果。

freedompixels
freedompixels
热度 35.95
最近更新 2026-06-07 10:34:45
分类:效率依赖:代码执行 / 读写文件应用场景:数据处理 / 文件转换

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add 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秒出结果