Using unicodedata.normalize in Python 2.7

Posted by dpitch40 on Stack Overflow See other posts from Stack Overflow or by dpitch40
Published on 2012-10-17T22:57:50Z Indexed on 2012/10/17 23:00 UTC
Read the original article Hit count: 290

Once again, I am very confused with a unicode question. I can't figure out how to successfully use unicodedata.normalize to convert non-ASCII characters as expected. For instance, I want to convert the string

u"Cœur"

To

u"Coeur"

I am pretty sure that unicodedata.normalize is the way to do this, but I can't get it to work. It just leaves the string unchanged.

>>> s = u"Cœur"
>>> unicodedata.normalize('NFKD', s) == s
True

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about python

Related posts about unicode