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.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xiaojingcc-0.0.3.tar.gz | 3.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xiaojingcc-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.3 kB
Release files / xiaojingcc-0.0.3.tar.gz
| Download URL | xiaojingcc-0.0.3.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9ab26489b2c1cc3b6bf6e3407effaaa19ee8b47bc1ed8a4b72e545ad81a3cf1
|
|
BLAKE2b-256 checksum How to use checksums |
f4092a51a24045bfe0958b1ace4c626bf01f69aaa6b1b91e6e1726ec15e1b10f
|
| 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.3-py3-none-any.whl
| Download URL | xiaojingcc-0.0.3-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86af572438ed131bfa25d633f3840939bc60062c71acc65d48363ecc1b0dbea3
|
|
BLAKE2b-256 checksum How to use checksums |
e8bfc9f90e0866fde2ca5de98ee3d7d45dcd90c52957fe1257bc72cc928905a9
|
| 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.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.