New submission from Thomas Kluyver <[email protected]>:
With the text 'abc€' copied to the clipboard, on Linux, where UTF-8 is the
default encoding:
Python 3.2.3 (default, Apr 12 2012, 21:55:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> root = tkinter.Tk()
>>> root.clipboard_get()
'abcâ\x82¬'
>>> 'abc€'.encode('utf-8').decode('latin-1')
'abcâ\x82¬'
I see the same behaviour in 2.7.3 as well (it returns a unicode string
u'abc\xe2\x82\xac').
If the clipboard is only accessible at a bytes level, I think clipboard_get
should return a bytes object. But I can reliably copy and paste non-ascii
characters between programs, so it looks like it's possible to return unicode.
----------
components: Tkinter
messages: 160378
nosy: takluyver
priority: normal
severity: normal
status: open
title: Tkinter clipboard_get() decodes characters incorrectly
type: behavior
versions: Python 2.7, Python 3.2
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue14777>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com