470,594 Members | 1,412 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

unicode encoding problem


Every time I think I understand unicode, I prove I don't.

I created a variable in interactive mode like this:
s = u''
where this character is the a-umlaut
that worked alright. Then I encoded it like this:
s.encode( 'latin1')

and it printed out a sigma (totally wrong)

then I typed this:
s.encode( 'utf-8')

Then it gave me two weird characters +

So how do I tell what encoding my unicode string is in, and how do I
retrieve that when I read it from a file?

Jul 19 '05 #1
2 1400
ga******@hotmail.com wrote:
So how do I tell what encoding my unicode string is in, and how do I
retrieve that when I read it from a file?


In interactive mode, you best avoid non-ASCII characters in a Unicode
literal.

In theory, Python should look at sys.stdin.encoding when processing
the interactive source. In practice, various Python releases ignore
sys.stdin.encoding, and just assume it is Latin-1. What is
sys.stdin.encoding on your system?

Regards,
Martin
Jul 19 '05 #2
On Thu, 28 Apr 2005 23:53:02 +0200, rumours say that "Martin v. Lwis"
<ma****@v.loewis.de> might have written:
In theory, Python should look at sys.stdin.encoding when processing
the interactive source. In practice, various Python releases ignore
sys.stdin.encoding, and just assume it is Latin-1. What is
sys.stdin.encoding on your system?


The difference between theory and practice is that in theory there is no
difference.
--
TZOTZIOY, I speak England very best.
"Be strict when sending and tolerant when receiving." (from RFC1958)
I really should keep that in mind when talking with people, actually...
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Bill Eldridge | last post: by
14 posts views Thread by wolfgang haefelinger | last post: by
27 posts views Thread by EU citizen | last post: by
4 posts views Thread by webdev | last post: by
7 posts views Thread by Robert | last post: by
9 posts views Thread by Gerry | last post: by
1 post views Thread by ujjwaltrivedi | last post: by
1 post views Thread by Victor Lin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.