Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40446

Re: Encoding problem in python

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <vlastimil.brom@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'error:': 0.05; 'python': 0.09; 'literal': 0.09; 'sep': 0.09; 'windows,': 0.09; 'gui': 0.11; 'subject:python': 0.11; '2.7': 0.13; 'library': 0.15; 'encoding': 0.15; '"u"': 0.16; '(note': 0.16; 'help?': 0.16; 'ignores': 0.16; 'mark,': 0.16; 'pyshell': 0.16; 'shell:': 0.16; 'unsupported': 0.16; 'wxpython': 0.16; 'skip:u 30': 0.17; 'unicode': 0.17; '(in': 0.18; 'shell': 0.18; '>>>': 0.18; 'input': 0.18; 'bit': 0.21; 'subject:problem': 0.22; 'header:In-Reply- To:1': 0.25; 'handling': 0.27; 'message-id:@mail.gmail.com': 0.27; 'skip:( 20': 0.28; '(unless': 0.29; 'url:mailman': 0.29; 'probably': 0.29; 'e.g.': 0.30; 'error': 0.30; 'url:python': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'builds': 0.33; 'idle': 0.33; 'traceback': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'another': 0.33; 'received:google.com': 0.34; 'needed': 0.35; 'built-in': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; 'characters': 0.36; 'limitation': 0.36; 'option': 0.37; 'usual': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'gives': 0.39; 'instead': 0.39; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'url:mail': 0.40; 'most': 0.61; 'charset:windows-1256': 0.61; 'solve': 0.62; 'mentioned': 0.63; 'more': 0.63; 'quotation': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type:content-transfer-encoding; bh=nFB1L86UpM9zdTmzYx9mihReveTQ0odmFqpjevPHdhI=; b=Mq4kgOi/Vqjlv3Xn2BFKGe8OkA/K8igACSnL+9uSD4lXZYF5+re/B3k+efZOrAtjOE lbryPODhDXHJuformobkC65Ci41tmjHaCm5UPjLeGYYfN7bRTot7epf7XMNgzTl/kjFv 50dSbTDLiV3NpkIFDy8QnLmflivzqClGeP3dDzBn/Ul1O1/7uP3wqcMTfR8Yu2E3P/NX BXnocg/MsbNAyN8AG78TiTItgDFKFXnyK80dDLDU0znWd0lRn837St+qORDEDAgt1cjC J3V3xU/jcEcaPZzksKZWOy6stJCiMwxSfr9Lcf43EyI35AXrN+6DMTzsXl38N73wA/4J TY1w==
MIME-Version 1.0
X-Received by 10.49.128.170 with SMTP id np10mr20981142qeb.37.1362404379578; Mon, 04 Mar 2013 05:39:39 -0800 (PST)
In-Reply-To <a70649cf-4b66-431f-bc97-e9af38b18e54@googlegroups.com>
References <a70649cf-4b66-431f-bc97-e9af38b18e54@googlegroups.com>
Date Mon, 4 Mar 2013 14:39:39 +0100
Subject Re: Encoding problem in python
From Vlastimil Brom <vlastimil.brom@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=windows-1256
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2838.1362404387.2939.python-list@python.org> (permalink)
Lines 55
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362404387 news.xs4all.nl 6934 [2001:888:2000:d::a6]:43388
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40446

Show key headers only | View raw


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 | NextPrevious in thread | Find similar | Unroll thread


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