Re: Encoding problem in python
If you use Arabic frequently on your system, I suggest to change your windows system locale from Region and Language in control panel (Administrative tab) and set to Arabic. -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding problem in python
On 2013-03-04 10:37, yomnasala...@gmail.com wrote: 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? Maybe it is not Python related. Did you get an exception? Can you send a full traceback? I suspect that the error comes from your terminal, and not Python. Please make sure that your terminal supports UTF-8 encoding. Alternatively, try creating a file with this content: # -*- encoding: UTF-8 -*- w=u'العربى' Save it as UTF-8 encoded file test.py (with an UTF-8 compatible editor, for example Geany) and run it as a command: python test.py If it works then it is sure that the problem is with your terminal. It will be an OS limitation, not Python's limitation. Best, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding problem in python
On Mon, 04 Mar 2013 01:37:42 -0800, yomnasalah91 wrote: 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? Firstly, please show the COMPLETE error, including the full traceback. Python errors look like (for example): py x = ord(100) Traceback (most recent call last): File stdin, line 1, in module TypeError: ord() expected string of length 1, but int found Copy and paste the complete traceback. Secondly, please describe your environment: - What operating system and version are you using? Linux, Windows, Mac OS, something else? Which version or distro? - Which console or terminal application? E.g. cmd.exe (Windows), konsole, xterm, something else? - Which shell? E.g. the standard Python interpreter, IDLE, bpython, something else? My guess is that this is not a Python problem, but an issue with your console. You should always have your console set to use UTF-8, if possible. I expect that your console is set to use a different encoding. In that case, see if you can change it to UTF-8. For example, using Gnome Terminal on Linux, I can do this: py w = u'العربى' py print w العربى and it works fine, but if I change the encoding to WINDOWS-1252 using the Set character encoding menu command, the terminal will not allow me to paste the string into the terminal. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Encoding problem in python
2013/3/4 yomnasala...@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 -- http://mail.python.org/mailman/listinfo/python-list