[issue22999] Copying emoji to Windows clipboard corrupts string in Python 3.3 and up
Cees Timmerman
report at bugs.python.org
Fri Dec 5 10:58:05 CET 2014
New submission from Cees Timmerman:
# http://stackoverflow.com/a/25678113/819417
def copy(data):
if not isinstance(data, unicode):
data = data.decode('mbcs')
OpenClipboard(None)
EmptyClipboard()
hCd = GlobalAlloc(GMEM_DDESHARE, 2 * (len(data) + 1))
pchData = GlobalLock(hCd)
wcscpy(ctypes.c_wchar_p(pchData), data)
GlobalUnlock(hCd)
SetClipboardData(CF_UNICODETEXT, hCd)
CloseClipboard()
Emoji "📋" (\U0001f400) is copied as "🐀" (\U0001f4cb), or "📋." turns to "📋" (note the period).
It works fine in Python 3.2.5.
----------
components: Unicode
messages: 232188
nosy: Cees.Timmerman, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Copying emoji to Windows clipboard corrupts string in Python 3.3 and up
type: behavior
versions: Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22999>
_______________________________________
More information about the Python-bugs-list
mailing list