Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40446
| References | <a70649cf-4b66-431f-bc97-e9af38b18e54@googlegroups.com> |
|---|---|
| Date | 2013-03-04 14:39 +0100 |
| Subject | Re: Encoding problem in python |
| From | Vlastimil Brom <vlastimil.brom@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2838.1362404387.2939.python-list@python.org> (permalink) |
2013/3/4 <yomnasalah91@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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Encoding problem in python yomnasalah91@gmail.com - 2013-03-04 01:37 -0800 Re: Encoding problem in python Laszlo Nagy <gandalf@shopzeus.com> - 2013-03-04 10:57 +0100 Re: Encoding problem in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-04 10:18 +0000 Re: Encoding problem in python Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-03-04 14:39 +0100
csiph-web