try to use unicode

Stefan Sonnenberg-Carstens stefan.sonnenberg at pythonmeister.com
Sat Nov 20 08:47:18 CET 2010


Am 20.11.2010 06:53, schrieb Mikael B:
> Hi.
>
> I'm learning python. python 2.6.6 on ubuntu 10.10 I'm swedish so I try 
> to use
> unicode to get swedish characters. I've checked wikipedia.
> utf-8 is said to be an unicode encoding..
>
> this is the test program:
>
> # -*- coding: utf-8 -*-
>
> import readline
>
> s=raw_input(u'Månadslön:')
>
> and this is the output:
>
> Traceback (most recent call last):
>   File "test_uni.py", line 5, in <module>
>     s=raw_input(u'Månadslön:')
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in 
> position 1: ordinal not in range(128)
>
> I'm doing something wrong...
>
> Mikael
>
Your console is not unicode ready.
Please take a look at the locale command and vars like
LC_ALL, LC_LANG etc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101120/fc3d4982/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stefan_sonnenberg.vcf
Type: text/x-vcard
Size: 223 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20101120/fc3d4982/attachment.vcf>


More information about the Python-list mailing list