Sometimes, we want to normalize Unicode with Python.
In this article, we’ll look at how to normalize Unicode with Python.
How to normalize Unicode with Python?
To normalize Unicode with Python, we call unicodedata.normalize
.
For instance, we write
print(ascii(unicodedata.normalize('NFC', 'u0061u0301')))
to call the unicodedata.normalize
method to normalize'u0061u0301'
.
We call it with 'NFC'
to return composed characters.
Then we call ascii
to ensure that non-ASCII codepoints are printed using escape syntax.
Conclusion
To normalize Unicode with Python, we call unicodedata.normalize
.