On 18/9/2013 15:40, MRAB wrote: > On 18/09/2013 20:28, stephen.bou...@gmail.com wrote: >> Thanks to everyone for their help. Using everyone's suggestions, this seems >> to work: >> >> import win32clipboard, win32con >> >> def getclipboard(): >> win32clipboard.OpenClipboard() >> s = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) >> win32clipboard.CloseClipboard() >> if '\0' in s: >> s = s[:s.index('\0')] >> return s >> > That'll look for a null character and, if it finds one, then look for > it again. Of course, that probably isn't an issue in practice. > > However, an alternative way of doing it is to use the .partition method: > > return s.partition('\0')[0]
So is the bug in Excel, in Windows, or in the Python library? Somebody is falling down on the job; if Windows defines the string as ending at the first null, then the Python interface should use that when defining the text defined with CF_UNICODETEXT. Or maybe it's an example of ill-defined Windows specs. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list