On Thu, 28 Nov 2013 14:22:01 -0800, mefistofelis wrote: > I have the following script however when the clipboard contents are > greek letters it fails to print them right. I have used all posible > encoding for greek letters including utf8 but to no avail so i just stay > with latin1. > > Can you suggest a solution? > > Here is the script: > > import win32clipboard > win32clipboard.OpenClipboard() > data = win32clipboard.GetClipboardData() > win32clipboard.CloseClipboard() > data = data.decode('latin1')
That cannot possibly work, since there are no Greek letters in Latin1. If you run this piece of code, you will see no Greek letters except for ยต MICRO SIGN. import unicodedata for i in range(256): c = chr(i).decode('latin-1') print c, unicodedata.name(c, "<no name>") I'm not an expert on Windows, but my guess is that the data coming out of the clipboard could be using one of these encodings: ISO-8859-7 # The code page used by some Greek versions of Windows. UTF-16be UTF-16 UTF-8 I'd try ISO-8859-7 and UTF-16be first, like this: import win32clipboard win32clipboard.OpenClipboard() data = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard() data = data.decode('UTF-16BE') -- Steven -- https://mail.python.org/mailman/listinfo/python-list