Is there a function in python which converts letters like é to e, or í to i?
Asked
Active
Viewed 320 times
1
-
https://github.com/avian2/unidecode; read also this comment https://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net#comment23803622_249087 – Ry- May 21 '17 at 20:59
1 Answers
5
Yes, you can filter and map the characters of a string through the following procedure:
from unicodedata import normalize, category
''.join([c for c in normalize('NFD',original) if category(c) != 'Mn'])
Here I filter these accents out of your question:
>>> original = 'Is there a function in python which converts letters like é to e, or í to i?'
>>> from unicodedata import normalize, category
>>> ''.join([c for c in normalize('NFD',original) if category(c) != 'Mn'])
'Is there a function in python which converts letters like e to e, or i to i?'

Willem Van Onsem
- 443,496
- 30
- 428
- 555