Frage

I'm doing some text processing, and I need all the text to be converted to lowercase, BUT the text is french and I need to maintain all the diacritics, so that "È" would get converted to "è", etc. If it helps at all, I actually don't need the final output as text, just a identifier (ex. a number) for each unique character (where "e" and "è" are different characters). Any suggestions?

War es hilfreich?

Lösung

Use Unicode strings:

>>> u"É".lower()
'é'

Andere Tipps

I think your problem is that you are converting to ascii. If you try something like

word = u"HÈLLO"
print word.lower()

That should do it

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top