Printing UTF-8
- From: sheldon.regular@xxxxxxxxx
- Date: 21 Sep 2006 13:47:50 -0700
I am new to unicode so please bear with my stupidity.
I am doing the following in a Python IDE called Wing with Python 23.
äöüs = "äöü"
print s
äöüprint s
'\xc3\xa4\xc3\xb6\xc3\xbc's
u'\xe4\xf6\xfc's.decode('utf-8')
u'\xe4\xf6\xfc'u = s.decode('utf-8')
u
äöüprint u.encode('utf-8')
äöüprint u.encode('latin1')
Why can't I get äöü printed from utf-8 and I can from latin1? How
can I use utf-8 exclusivly and be able to print the characters?
I also did the same thing an the same machine in a command window...
ActivePython 2.3.2 Build 230 (ActiveState Corp.) based on
Python 2.3.2 (#49, Oct 24 2003, 13:37:57) [MSC v.1200 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
äöüs = "äöü"
print s
'\x84\x94\x81's
Traceback (most recent call last):s.decode('utf-8')
File "<stdin>", line 1, in ?
UnicodeDecodeError: 'utf8' codec can't decode byte 0x84 in position 0:
unexpected code byte
Traceback (most recent call last):u = s.decode('utf-8')
File "<stdin>", line 1, in ?
UnicodeDecodeError: 'utf8' codec can't decode byte 0x84 in position 0:
unexpected code byte
Why such a difference from the IDE to the command window in what it can
do and the internal representation of the unicode?
Thanks,
Shel
.
- Follow-Ups:
- Re: Printing UTF-8
- From: John Machin
- Re: Printing UTF-8
- Prev by Date: Re: Strange behaviour of 'is'
- Next by Date: Re: newbe's re question
- Previous by thread: Weekly Python Patch/Bug Summary ** REVISED **
- Next by thread: Re: Printing UTF-8
- Index(es):
Relevant Pages
|
|