Encoding problem in python
Vlastimil Brom
vlastimil.brom at gmail.com
Mon Mar 4 08:39:39 EST 2013
2013/3/4 <yomnasalah91 at gmail.com>:
> I have a problem with encoding in python 27 shell.
>
> when i write this in the python shell:
>
> w=u'العربى'
>
> It gives me the following error:
>
> Unsupported characters in input
>
> any help?
> --
> http://mail.python.org/mailman/listinfo/python-list
Hi,
I guess, you are using the built-in IDLE shell with python 2.7 and
this is a specific limitation of its handling of some unicode
characters (in some builds and OSes - "narrow"-unicode, Windows, most
likely?) and its specific error message - not the usual python
traceback mentioned in other posts).
If it is viable, using python 3.3 instead would solve this problem for IDLE:
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600
32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> w='العربى'
>>> w
'العربى'
(note the missing "u" in unicode literal before the starting quotation
mark, which would be the usual usage in python 3, but python 3.3 also
silently ignores u"..." for compatibility.)
>>> w=u'العربى'
>>> w
'العربى'
>>>
If python 2.7 is required, another shell is probably needed (unless I
am missing some option to make IDLE work for this input);
e.g. the following works in pyshell - part of the wxpython GUI library
http://www.wxpython.org/
>>> w=u'العربى'
>>> w
u'\u0627\u0644\u0639\u0631\u0628\u0649'
>>> print w
العربى
>>>
hth,
vbr
More information about the Python-list
mailing list