trouble w/ unicode file
salgado at freeshell.org
Sun Jan 25 16:13:48 CET 2004
On Sun, 2004-01-25 at 06:54, Serge Orlov wrote:
> "Guilherme Salgado" <salgado at freeshell.org> wrote in message news:mailman.752.1074995324.12720.python-list at python.org...
> > Hi there,
> > I have a python source file encoded in unicode(utf-8) with some
> > iso8859-1 strings. I've encoded this file as utf-8 in the hope that
> > python will understand these strings as unicode (<type 'unicode'>)
> > strings whithout the need to use unicode() or u"" on these strings. But
> > this didn't happen.
> You hoped, but you forgot to pray <wink> Why do you think Python
> should behave this way? There is (an experimental?) option -U that
Ok, ok. I'll remember to pray next time. :-)
I need to store unicode strings(declared in files) in ZODB, but i don't
want to use u"" around all my strings (cause most of them are latin-1),
so i think storing the file as unicode will work. Is there a better way
for doing this?
> forces all string literals to be unicode. Obviously if you use this option
> your sources won't be easily distributable to other people
> > Am I expecting something that really shoudn't happen or we have a bug?
> We have a bug here as well. But in your code. The coding must
> be the same as the coding of your source file. bar.py must be:
> #-*- coding: latin-1 -*-
> x = 'ééééáááááííí'
> print x, type(x)
I didn't understand this (even after some pray) :-)
My file is encoded in utf-8, look:
$ file bar.py
bar.py: UTF-8 Unicode text
Why should i declare it as latin1 encoded though?
This email has been inspected by Hans Blix, who has reported that no
weapons of mass destruction were used in its construction.
Read his report here:
More information about the Python-list