Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'elements.': 0.05; 'python': 0.09; 'delimiter': 0.09; 'encode': 0.09; 'processing,': 0.09; 'subject:characters': 0.09; 'cc:addr:python-list': 0.10; 'codec': 0.16; 'directly?': 0.16; 'string': 0.17; 'wrote:': 0.17; 'bytes': 0.17; 'app': 0.19; 'skip:" 30': 0.20; 'cc:2**0': 0.23; 'errors': 0.23; 'originally': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'skip:" 20': 0.26; '(most': 0.27; 'converting': 0.27; 'fine': 0.28; 'unlikely': 0.29; 'character': 0.29; 'convert': 0.29; "i'm": 0.29; 'error': 0.30; 'file': 0.32; 'traceback': 0.33; 'handle': 0.33; "can't": 0.34; 'saved': 0.35; 'pm,': 0.35; 'something': 0.35; 'characters': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'things': 0.38; 'received:192': 0.39; 'application': 0.40; 'received:192.168': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'further': 0.61; 'real': 0.61; 'kind': 0.61; 'fun': 0.64; 'results': 0.65; 'skip:c 50': 0.66; 'header:Reply- To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84 Date: Fri, 09 Nov 2012 12:47:42 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: danielk Subject: Re: Printing characters outside of the ASCII range References: <3d4644f8-ab88-41c5-9a52-2a5678dd64c0@googlegroups.com> In-Reply-To: <3d4644f8-ab88-41c5-9a52-2a5678dd64c0@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:YtDWsnbtDUTgD0NojIUiMGNh+B051nBJ3JUsSSG5oDJ CHYDOhXI7Anl+M6FdaG+Lp0UA6v3Ztk2pOKAvQrzp0lxSLiYWL tHG/kkWCrnFzJNsoiNO7DHE17NK150XwduSFsHcRp0eXLBd4L6 ckHMx20liNxPTeIdFLE8GFOkPspg/kKSILOQ8rCu1Al+b1noLD HEHXO+GQwxXHOpRhH0p8bIAW18lAMckblYoM7hxfYcTtQra59O Yz7rW5jv2Fc/6GJxUiuH8UlXM9iYewmcD5BqahKa8FgMl7L6h9 BDA+O1AlNgUlWn20DL4wLYleTAjTpPuBb256f8VPIevHBka3g= = Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352483285 news.xs4all.nl 6902 [2001:888:2000:d::a6]:39597 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33043 On 11/09/2012 12:17 PM, danielk wrote: > I'm converting an application to Python 3. The app works fine on Python 2. > > Simply put, this simple one-liner: > > print(chr(254)) > > errors out with: > > Traceback (most recent call last): > File "D:\home\python\tst.py", line 1, in > print(chr(254)) > File "C:\Python33\lib\encodings\cp437.py", line 19, in encode > return codecs.charmap_encode(input,self.errors,encoding_map)[0] > UnicodeEncodeError: 'charmap' codec can't encode character '\xfe' in position 0: character maps to > > I'm using this character as a delimiter in my application. > > What do I have to do to convert this string so that it does not error out? What character do you want? What characters do your console handle directly? What does a "delimiter" mean for your particular console? Or are you just printing it for the fun of it, and the real purpose is for further processing, which will not go to the console? What kind of things will it be separating? (strings, bytes ?) Clearly you originally picked it as something unlikely to occur in those elements. When those things are combined with a separator between, how are the results going to be used? Saved to a file? Printed to console? What? -- DaveA