Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'problem?': 0.07; 'string': 0.09; 'subject:characters': 0.09; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'non- ascii': 0.16; 'repr': 0.16; 'string:': 0.16; 'subject:non': 0.16; 'tuple': 0.16; 'unicode.': 0.16; 'wrote:': 0.18; 'byte': 0.24; 'string,': 0.24; 'unicode': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'probably': 0.32; 'quite': 0.32; 'fri,': 0.33; 'there,': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'data,': 0.36; 'starting': 0.37; 'nov': 0.38; 'handle': 0.38; 'to:addr:python- list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'easy': 0.60; 'worry': 0.60; "you're": 0.61; 'show': 0.63; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=zfXIFGuWtT4Rz5OscfuNvQJb1uUDN097XkFa6+sQ6xg=; b=vqBWus0ijvWilcxwUenrc/v0JtV+FzhSPR5FAHvQBlEb9i34Rp4gJfFl2sdQPCtZy4 0kOQnt/UAykkJSl9bvJzyOXyU/5IUXjfb50bgQDWBFWYGi8i+dDiv5DTozkMcpxwOrtd ZgKzWr+E9+LmJgJl9tGwviCMcXtBaJJvuSWFPionPn8jzZsqGunbgBAghQkjeRGcO4qp a3jG4OBUIGUNS8LeFHM6ohUtsIRtrhVt8QWckDUMohmBVajdj23h/Ugjnh6I1CZ80/3n qkHKFraeTPtOWyPW7wKLumFFn7PWZo9ZyWpRiUSc7eevQTzFNkeOLsQzukd1DRuIy1/E MhRQ== MIME-Version: 1.0 X-Received: by 10.68.110.196 with SMTP id ic4mr2397004pbb.84.1383232005512; Thu, 31 Oct 2013 08:06:45 -0700 (PDT) In-Reply-To: References: Date: Fri, 1 Nov 2013 02:06:45 +1100 Subject: Re: tuple __repr__ non-ascii characters From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383232009 news.xs4all.nl 15999 [2001:888:2000:d::a6]:60853 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58182 On Fri, Nov 1, 2013 at 1:59 AM, Ya=C5=9Far Arabac=C4=B1 wrote: > Is there a better way to handle this problem? There is, but I don't know how easy it'll be. In Python 3, the repr of a tuple will show Unicode strings as Unicode. :) For what you're showing there, I'm not actually quite sure what's going on. Is the string a Unicode string, or a byte string? If it's a byte string (which I suspect, since it's coming up as \xfe and the character you're showing us isn't U+00FE), then you have to worry about encodings. If you're using it to store non-ASCII data, you probably want to be using a Unicode string: a =3D u"ya=C5=9Far" The best solution is definitely to move to Python 3, though - if you can. Do you have much code to migrate, or are you starting fresh? Are there any libraries/modules that you need that don't support Py3? ChrisA