[Python-de] Umlaute auf "ähnliche" ASCII-Zeichen abbilden, z.B. ä->a (unicodedata?)

Hartmut Goebel h.goebel at goebel-consult.de
Fr Jan 4 14:35:39 CET 2013


Hallo,

Am 04.01.2013 11:38, schrieb Felix Schwarz:
> - Es muss eigentlich nur für die deutsche Sprache funktionieren, alles andere
>   ist nur "nettes Extra". Auf gar keinen Fall asiatische Sprachen.
Ich verwende dafür diese paar Zeilen:

def _strip_accents(s):
   return ''.join((c
                   for c in unicodedata.normalize('NFD', s)
                   if unicodedata.category(c) != 'Mn'))


-- 
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP

Goebel Consult
http://www.goebel-consult.de

Monatliche Kolumne:
http://www.cissp-gefluester.de/2012-02-bring-your-own-life-glosse
Blog: http://www.goebel-consult.de/blog/20060215

Goebel Consult ist Mitglied bei http://www.7-it.de/

-------------- nächster Teil --------------
Ein Dateianhang mit HTML-Daten wurde abgetrennt...
URL: <http://mail.python.org/pipermail/python-de/attachments/20130104/f83f9793/attachment.html>
-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : smime.p7s
Dateityp    : application/pkcs7-signature
Dateigröße  : 3758 bytes
Beschreibung: S/MIME Kryptografische Unterschrift
URL         : <http://mail.python.org/pipermail/python-de/attachments/20130104/f83f9793/attachment.bin>


Mehr Informationen über die Mailingliste python-de