Skip to main content

pyunormalize

A pure Python implementation of the Unicode normalization algorithm independent from the Python core Unicode database. This package supports version 15.1 of the Unicode standard (released in September 2023). It has been thoroughly tested against the Unicode test file.

For the formal specification of the Unicode normalization algorithm, see Section 3.11, Normalization Forms, in the Unicode core specification.

Installation

The easiest method to install is using pip:

pip install pyunormalize

UCD version

To get the version of the Unicode character database currently used:

>>> from pyunormalize import UCD_VERSION
>>> UCD_VERSION
'15.1.0'

Example usage

>>> from pyunormalize import NFC, NFD, NFKC, NFKD
>>> s = "élève"  # "\u00E9\u006C\u00E8\u0076\u0065"
>>> nfc = NFC(s)
>>> nfd = NFD(s)
>>> nfc == s
True
>>> nfd == nfc
False
>>> " ".join([f"{ord(x):04X}" for x in nfc])
'00E9 006C 00E8 0076 0065'
>>> " ".join([f"{ord(x):04X}" for x in nfd])
'0065 0301 006C 0065 0300 0076 0065'
>>>
>>> s = "⑴ ffi ²"
>>> NFC(s), NFKC(s), NFD(s), NFKD(s)
('⑴ ffi ²', '(1) ffi 2', '⑴ ffi ²', '(1) ffi 2')

>>> from pyunormalize import normalize
>>> normalize("NFKD", "⑴ ffi ²")
'(1) ffi 2'
>>> forms = ["NFC", "NFD", "NFKC", "NFKD"]
>>> [normalize(f, "\u017F\u0307\u0323") for f in forms]
['ẛ̣', 'ẛ̣', 'ṩ', 'ṩ']

Related resources

This implementation is based on the following resources:

Licenses

The code is available under the MIT license.

Usage of Unicode data files is governed by the UNICODE TERMS OF USE. Further specifications of rights and restrictions pertaining to the use of the Unicode data files and software can be found in the Unicode Data Files and Software License, a copy of which is included as UNICODE-LICENSE.

Metadata

Release files for pyunormalize-micropip 15.1.0

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

Source distribution (sdist)

Source distribution for pyunormalize-micropip 15.1.0
File Size Uploaded
pyunormalize_micropip-15.1.0.tar.gz 515.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyunormalize-micropip 15.1.0
File Interpreter ABI Platform
pyunormalize_micropip-15.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.0 MB

Release files / pyunormalize_micropip-15.1.0.tar.gz

Download URL pyunormalize_micropip-15.1.0.tar.gz
Size 515.3 kB
Tags Source
SHA-256 checksum
How to use checksums
56ec783f561546b95ff3c8a90ccdc8f1461f6be71facef27c53e77d50dedb2fd
BLAKE2b-256 checksum
How to use checksums
92697ead22afe17c7baba6134939011de65fd2cc8c7d4b6f87f7eedd4fbaad5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.2

Release files / pyunormalize_micropip-15.1.0-py3-none-any.whl

Download URL pyunormalize_micropip-15.1.0-py3-none-any.whl
Size 516.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e9d54d29af940a5b3a1fb13d4520ec2082f0853f5fec8869dc03885a62c5d5b
BLAKE2b-256 checksum
How to use checksums
f3f0c73d9a51d1bab11112f70cb88feff3613f244a3905018dff30c46c79412d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

15.1.0 This release

2 release files

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