Metadata-Version: 2.4
Name: xml-encoding-detector
Version: 0.3.0
Summary: Lightweight XML encoding detector for Python.
Author: namnv0410
License: MIT
Project-URL: Homepage, https://github.com/namnv0410-ship-it/xml-encoding-detector
Project-URL: Repository, https://github.com/namnv0410-ship-it/xml-encoding-detector
Project-URL: Issues, https://github.com/namnv0410-ship-it/xml-encoding-detector/issues
Keywords: xml,encoding,unicode,utf8,utf16
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lxml>=5.0
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == "test"
Requires-Dist: pytest-cov>=5.0; extra == "test"
Provides-Extra: dev
Requires-Dist: ruff>=0.7; extra == "dev"
Dynamic: license-file

xml-encoding-detector

Lightweight XML encoding detector for Python.



Features

UTF-8 BOM detection

UTF-16 LE/BE BOM detection

UTF-32 LE/BE BOM detection

XML declaration parsing

Encoding alias normalization

Installation

pip install xml-encoding-detector

Usage

from xml\_encoding\_detector import (

&#x20;   detect\_encoding,

)



xml = (

&#x20;   b'<?xml version="1.0" '

&#x20;   b'encoding="Shift\_JIS"?>'

)



result = detect\_encoding(xml)



print(result.encoding)

print(result.confidence)

print(result.source)

Example Output

shift\_jis

0.9

xml-declaration

