On this page
unicodedata.normalize
Prev: unicodedata.name | Up: unicodedata | Next: unicodedata.numeric
Rel: unicodedata.bidirectional, unicodedata.category, unicodedata.combining, unicodedata.decimal
Ref: docs.python.org — unicodedata.normalize
Tags: #public #python3 #stdlib #unicodedata
Import
import unicodedata
from unicodedata import normalize
Signature & Overview
unicodedata.normalize(form, unistr, /)
Return the normal form 'form' for the Unicode string unistr.
Usage
import unicodedata
composed = 'café'
decomposed = 'cafe\u0301'
assert composed != decomposed
assert unicodedata.normalize('NFC', decomposed) == composed
Gotchas
- Always normalize to
NFCbefore comparing filenames/usernames (macOS HFS+/APFS frequently stores decomposedNFDstrings).
REPL Inspect
from unicodedata import normalize
help(normalize)
Linked from
Related notes
- tuts/python3/stdlib_module/unicodedata/name Linked here; links to this page; shared tags: #stdlib, #unicodedata
- tuts/python3/stdlib_module/unicodedata/numeric Linked here; links to this page; shared tags: #stdlib, #unicodedata
- tuts/python3/stdlib_module/unicodedata Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/unicodedata/bidirectional Linked here; shared tags: #stdlib, #unicodedata
- tuts/python3/stdlib_module/unicodedata/category Linked here; shared tags: #stdlib, #unicodedata
- tuts/python3/stdlib_module/unicodedata/combining Linked here; shared tags: #stdlib, #unicodedata
- tuts/python3/stdlib_module/unicodedata/decimal Linked here; shared tags: #stdlib, #unicodedata
- tuts/python3/stdlib_module/unicodedata/decomposition shared tags: #stdlib, #unicodedata
- tuts/python3/stdlib_module/unicodedata/digit shared tags: #stdlib, #unicodedata
- tuts/python3/stdlib_module/unicodedata/east_asian_width shared tags: #stdlib, #unicodedata