Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76525
| Date | 2014-08-19 09:44 +1000 |
|---|---|
| Subject | Python 2.7 IDLE Win32 interactive, pasted characters i- wrong encoding |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13123.1408405485.18130.python-list@python.org> (permalink) |
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 € is 0x80 in CP-1252" 'U+20AC is € 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 -*- >>> u"U+20AC is € is 0x80 in CP-1252" u'U+20AC is \x80 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. 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? ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Python 2.7 IDLE Win32 interactive, pasted characters i- wrong encoding Chris Angelico <rosuav@gmail.com> - 2014-08-19 09:44 +1000
csiph-web