Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'encoding': 0.05; 'subject:Python': 0.06; 'fixes': 0.07; 'url:msdn': 0.07; 'utf-8': 0.07; 'directions': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:activepython': 0.09; 'url:activestate': 0.09; 'used.': 0.09; 'python': 0.11; 'jan': 0.12; 'suggest': 0.14; '2.7': 0.14; 'random': 0.14; 'windows': 0.15; 'avail': 0.16; 'encodings': 0.16; 'failure.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'reliably': 0.16; 'unlikely': 0.16; 'url:85)': 0.16; 'url:pywin32': 0.16; 'url:windows': 0.16; 'utf8': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'print': 0.22; 'header:User-Agent:1': 0.23; 'unicode': 0.24; 'versions': 0.24; 'source': 0.25; 'script': 0.25; 'handling': 0.26; 'possibly': 0.26; 'query': 0.26; 'right.': 0.26; 'switch': 0.26; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'patch': 0.29; 'skip:g 30': 0.30; 'easier': 0.31; "skip:' 10": 0.31; 'quite': 0.32; 'text': 0.33; 'fri,': 0.33; 'could': 0.34; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'impression': 0.36; 'should': 0.36; 'searching': 0.37; 'url:microsoft': 0.37; 'being': 0.38; 'nov': 0.38; 'url:library': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'improved': 0.60; 'letters': 0.60; 'received:173': 0.61; "you're": 0.61; 'kind': 0.63; 'such': 0.63; 'url:en-us': 0.68; 'default': 0.69; 'url:4': 0.69; 'url:%1': 0.72; 'greek': 0.84; 'posible': 0.84; 'received:fios.verizon.net': 0.84; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Cannot print greek letters in Python 2.6 Date: Thu, 28 Nov 2013 20:46:07 -0500 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-254-207.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385689587 news.xs4all.nl 15871 [2001:888:2000:d::a6]:39798 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60747 On 11/28/2013 5:48 PM, Chris Angelico wrote: > On Fri, Nov 29, 2013 at 9:22 AM, 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. When you use a 3rd patch module like 'win32clipboard', you should give a url for the source or doc. Were you using http://docs.activestate.com/activepython/2.4/pywin32/win32clipboard.html There are other programs on Pypi, such as pyclip. > You need to know what encoding is actually being used. Attempting to > decode using arbitrary encodings is doomed to failure. Possibly > Windows is using some kind of global default encoding, or possibly > you can query the other program for its encoding, but you're unlikely > to succeed by pointing the decode gun in random directions and > firing. Searching "windows clipboard encoding" return pages such as http://stackoverflow.com/questions/1929812/how-does-cut-and-paste-affect-character-encoding-and-what-can-go-wrong http://msdn.microsoft.com/en-us/library/windows/desktop/ms649015%28v=vs.85%29.aspx http://www.dmst.aueb.gr/dds/sw/outwit/winclip.html These suggest that there should be utf-8 and/or utf-16le versions of any text pasted. http://docs.activestate.com/activepython/2.4/pywin32/win32clipboard__GetClipboardData_meth.html say you could use GetClipboardData(CF_UNICODETEXT) which should reliably give you utf-16le. I get the impression that CF_TEXT should be utf-8 but might not be. EnumClipboardFormats will let you see what is available. > Incidentally, you may find things easier if you switch to Python 3.3 > - quite a bit of Unicode handling is improved in Py3. At least use the *latest* version of 2.7 to get whatever unicode fixes that have been made to 2.x. -- Terry Jan Reedy