Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'win32': 0.03; 'subject:IDLE': 0.04; 'subject:Python': 0.06; '(b)': 0.07; '-*-': 0.07; 'encoded': 0.07; 'interpreter.': 0.07; 'utf-8': 0.07; 'coding:': 0.09; 'cookie': 0.09; 'executed': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:2.7': 0.09; 'subject:characters': 0.09; 'python': 0.11; 'jan': 0.12; 'characters:': 0.16; 'editor,': 0.16; 'idle,': 0.16; 'idle.': 0.16; 'literal.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject: \n ': 0.16; 'tab,': 0.16; 'win7': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'pointed': 0.19; 'seems': 0.21; 'coding': 0.22; 'header:User- Agent:1': 0.23; '(a)': 0.24; 'unicode': 0.24; 'together.': 0.24; 'source': 0.25; 'compiled': 0.26; 'this:': 0.26; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'fixed': 0.29; 'chris': 0.29; 'url:bugs': 0.29; '2009': 0.29; 'character': 0.29; "doesn't": 0.30; 'statement': 0.30; 'skip:( 20': 0.30; 'code': 0.31; '>>>>': 0.31; 'dated': 0.31; 'fine,': 0.31; 'subject:- ': 0.31; 'url:python': 0.33; 'beginning': 0.33; 'noticed': 0.34; 'updated': 0.34; 'problem': 0.35; 'editor': 0.35; 'but': 0.35; 'idle': 0.36; 'done': 0.36; 'url:org': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'does': 0.39; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'first': 0.61; 'more': 0.64; 'talking': 0.65; 'mar': 0.68; 'default': 0.69; 'led': 0.72; '2014,': 0.84; 'execution.': 0.84; 'lasting': 0.84; 'received:fios.verizon.net': 0.84; 'suspicion': 0.84; '\xe2\x82\xac': 0.84; '2013,': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Python 2.7 IDLE Win32 interactive, pasted characters i- wrong encoding Date: Tue, 19 Aug 2014 05:03:49 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 57 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408439077 news.xs4all.nl 2904 [2001:888:2000:d::a6]:52070 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76549 On 8/18/2014 7:44 PM, Chris Angelico wrote: > Python 3 works fine, at least for BMP characters: > > Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600 > 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. >>>> u"U+20AC is =E2=82=AC is 0x80 in CP-1252" > 'U+20AC is =E2=82=AC is 0x80 in CP-1252' >>>> ascii(_) > "'U+20AC is \\u20ac is 0x80 in CP-1252'" > > Python 2 doesn't: > > Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. >>>> # -*- coding: utf-8 -*- I don't think this has any lasting effect in interactive mode. Each=20 statement is compiled and executed separatedly. In Idle, this is done=20 with exec(). >>>> u"U+20AC is =E2=82=AC is 0x80 in CP-1252" > u'U+20AC is \x80 is 0x80 in CP-1252' Better than what I get on my 3.4.1 Win7 U+20AC is =C2=80 is 0x80 in CP-1252 > The pasted-in character is encoded CP-1252 instead of being a Unicode > literal. Beginning the session with the coding cookie doesn't make any > difference; nor does the Options|Configure IDLE, General tab, Default > Source Encoding, which I have set to UTF-8. My suspicion is that both > of these will work for editing files, but not for interactive > execution. # -*- coding: utf-8 -*- print(u"U+20AC is =E2=82=AC is 0x80 in CP-1252") works > Poking around led me to this: > http://bugs.python.org/issue4454 > which pointed me to > http://bugs.python.org/issue4008 > but (a) that claims to have been fixed in Jan 2009 (I first noticed > this issue in 2.7.4 dated 2013, and then I updated to 2.7.8 in case it > had been fixed), and (b) it seems to be talking about the editor, not > the interactive interpreter. > > How do I get IDLE to accept Unicode in literals? The problem is python exec, not Idle. Use the editor and submit coding=20 and code together. --=20 Terry Jan Reedy