Categories
Python Answers

How to normalize Unicode with Python?

Spread the love

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', '\u0061\u0301')))

to call the unicodedata.normalize method to normalize'\u0061\u0301'.

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *