Skip to main content

xiaojingcc

English | 中文

编码损坏(乱码)的检测与修复。

安装

pip install xiaojingcc

用法

from xiaojingcc import decode_bytes, looks_mojibake, repair

looks_mojibake("测试")      # True
repair("测试")              # '测试'
repair("正常的中文")           # 原样返回

decode_bytes(b"²âÊÔ", ("utf-8", "gbk"))   # ('测试', 'gbk')

说明

典型场景是 UTF-8 字节被按 latin-1 解码后再存成 UTF-8,中文变成 测试 这样的串。repair 按 latin-1 还原字节再按 UTF-8 解码,失败时原样返回。decode_bytes 按候选编码顺序试,全部失败抛 ValueError——不猜一个替代字符糊过去。

许可证

MIT


English

Detect and repair encoding damage (mojibake).

Install

pip install xiaojingcc

Usage

from xiaojingcc import decode_bytes, looks_mojibake, repair

looks_mojibake("测试")      # True
repair("测试")              # '测试'
repair("正常的中文")           # 原样返回

decode_bytes(b"²âÊÔ", ("utf-8", "gbk"))   # ('测试', 'gbk')

Notes

The classic case is UTF-8 bytes decoded as latin-1 and saved again, turning text into 测试. repair re-encodes as latin-1 and decodes as UTF-8, returning the input unchanged when that fails. decode_bytes tries candidate encodings in order and raises ValueError when none works.

License

MIT

Metadata

Release files for xiaojingcc 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xiaojingcc 0.0.2
File Size Uploaded Provenance
xiaojingcc-0.0.2.tar.gz 3.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for xiaojingcc 0.0.2
File Interpreter ABI Platform
xiaojingcc-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / xiaojingcc-0.0.2.tar.gz

Download URL xiaojingcc-0.0.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
68fc5d6511c478f8faaf3ad5d9278c221334e07ea518c70b89e22960c033fbac
BLAKE2b-256 checksum
How to use checksums
195aed270cb83863f3fb2505a7d216d8afec1e1a9d4d595d95afa724ce85e7e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Release files / xiaojingcc-0.0.2-py3-none-any.whl

Download URL xiaojingcc-0.0.2-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bee6563a445c0a081daeafa9c7ddc1583bcce524f0b3a1e3eedc6c3c70d8f11f
BLAKE2b-256 checksum
How to use checksums
b7cc9de12a28e068e93ce3126a788339dff1e692f55f97bab367fd8bbf59758f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.11

Security for xiaojingcc 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page