A library for Unicode normalization (NFC, NFD, NFKC, NFKD) independent of Python's core Unicode database.
Project description
pyunormalize
A pure-Python implementation of the Unicode normalization algorithm. This package conforms strictly to version 17.0 of the Unicode Standard, released in September 2025, by using its own dedicated data derived from the Unicode character database (UCD) corresponding to that version. This approach ensures total independence from the Unicode version built into the host Python environment.
All normalization functions (NFC, NFD, NFKC, and NFKD) have been thoroughly tested against the official Unicode test file for accuracy.
Python support policy
This package requires Python 3.8 or newer.
In version 17.0.0 of pyunormalize, support for Python 3.6 and 3.7 was dropped. These interpreters are past end-of-life and cannot be used reliably with modern Python packaging and installation tools.
Installation and updates
To install the package, run:
pip install pyunormalize
To upgrade to the latest version, run:
pip install pyunormalize --upgrade
Changelog
Check out the latest updates and changes here.
Unicode character database (UCD) version
Retrieve the version of the Unicode character database in use:
>>> from pyunormalize import UCD_VERSION
>>> print(UCD_VERSION)
17.0.0
Usage examples
Base normalization forms
This section demonstrates the use of the NFC, NFD, NFKC, and NFKD functions for specific normalization tasks.
from pyunormalize import NFC, NFD, NFKC, NFKD
# Example string with accented characters
text = "élève" # "\u00E9\u006C\u00E8\u0076\u0065"
# Normalize to different forms
nfc = NFC(text)
nfd = NFD(text)
# Comparisons
print(nfc == text) # True (NFC preserves the original composed form)
print(nfd == nfc) # False (NFD decomposes accented characters)
# Display Unicode code points in hexadecimal
print("NFC: " + " ".join([f"{ord(c):04X}" for c in nfc]))
print("NFD: " + " ".join([f"{ord(c):04X}" for c in nfd]))
# Output:
# NFC: 00E9 006C 00E8 0076 0065
# NFD: 0065 0301 006C 0065 0300 0076 0065
Using the generic normalize function
The normalize function can be used to apply any normalization form programmatically.
from pyunormalize import normalize
text = "désaffiliât"
print("Input\t" + " ".join([f"{ord(c):04X}" for c in text]))
# Apply each of the four forms
forms = ["NFC", "NFD", "NFKC", "NFKD"]
for form in forms:
normalized_text = normalize(form, text)
hex_repr = " ".join([f"{ord(c):04X}" for c in normalized_text])
print(f"{form}\t{hex_repr}")
# Output:
# Input 0064 00E9 0073 0061 FB03 006C 0069 00E2 0074
# NFC 0064 00E9 0073 0061 FB03 006C 0069 00E2 0074
# NFD 0064 0065 0301 0073 0061 FB03 006C 0069 0061 0302 0074
# NFKC 0064 00E9 0073 0061 0066 0066 0069 006C 0069 00E2 0074
# NFKD 0064 0065 0301 0073 0061 0066 0066 0069 006C 0069 0061 0302 0074
Related resources
This implementation is based on the following resources:
- The Unicode Standard, Version 17.0 – Core Specification, Section 3.11: “Normalization Forms”
- Unicode Standard Annex #15: “Unicode Normalization Forms,” revision 57
Licenses
The code is available under the terms of 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyunormalize-17.0.0.tar.gz.
File metadata
- Download URL: pyunormalize-17.0.0.tar.gz
- Upload date:
- Size: 53.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0949a3e56817e287febcaf1b0cc4b5adf0bb107628d379335938040947eec792
|
|
| MD5 |
d3cb78bb5a74951c6caa20d69534d89f
|
|
| BLAKE2b-256 |
25abb912c484cfb96ba4834efe050bbf10c9e157bd8189eb859aefba8712b136
|
File details
Details for the file pyunormalize-17.0.0-py3-none-any.whl.
File metadata
- Download URL: pyunormalize-17.0.0-py3-none-any.whl
- Upload date:
- Size: 51.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0d93b076f938db2b26d319d04f2b58505d1cd7a80b5b72badbe7d1aa4d2a31c
|
|
| MD5 |
7131782b63af1d6124f73f41a56613a4
|
|
| BLAKE2b-256 |
928061512483dc509e3ae8a42fb143479d1e406ce1d91f8f08d538a3dde39c6d
|