[Python-de] UTF-8 Python Datei
Andreas Pakulat
apaku at gmx.de
Mon Apr 25 22:01:14 CEST 2005
On 25.Apr 2005 - 20:53:49, Albert Hermeling wrote:
> Am Montag, 25. April 2005 20:49 schrieb Simon Pamies:
>
> Guten Abend Simon,
>
> > > print type("Äpfel")
> >
> > print type(u"Äpfel")
> >
> > > <type 'unicode'> <------- Richtig!!
> > > <type 'str'> <------- Warum ist das ein String???
>
> Das Skript ist! unicode warum ist dann type("Äpfel") im unicode Skript nicht
> von type unicode?
Wenn ich mich da jetzt nicht vertuhe stimmt das nicht, deine Datei ist
in UTF-8 gespeichert - einem Unicode Encoding. Dein Skript ist
ein Byte-Strom für python und dieses kann beim Einlesen nicht wissen
welches Encoding du für non-ascii Zeichen benutzt hast. IIRC gibts nen
Kommentar um anzugeben, dass die Datei in einem bestimmten Encoding
gespeichert ist, aber ich hab grad den "Zeiger" verlegt ;-)
Andreas
--
You are wise, witty, and wonderful, but you spend too much time reading
this sort of trash.