Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'encoded': 0.05; 'badly': 0.07; 'utf-8': 0.07; 'encode': 0.09; 'encoding.': 0.09; 'portable': 0.09; 'cc:addr:python-list': 0.10; 'encoding': 0.15; 'skip:p 40': 0.15; 'codec': 0.16; 'decode': 0.16; 'ordinal': 0.16; 'partly': 0.16; 'subject:Unicode': 0.16; 'settings': 0.16; 'unicode': 0.17; '>>>': 0.18; '(or': 0.18; 'received:209.85.214.174': 0.21; '"",': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'handling': 0.27; 'i.e.': 0.27; 'message-id:@mail.gmail.com': 0.27; '>>>>': 0.29; 'ansi': 0.29; 'character': 0.29; 'file': 0.32; 'print': 0.32; 'traceback': 0.33; 'likely': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'text': 0.34; 'doing': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'thank': 0.36; 'problems': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'received:209.85.214': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'results': 0.65; 'receive': 0.71; 'capability': 0.91; 'step.': 0.91; 'cause,': 0.93 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 :cc:content-type:content-transfer-encoding; bh=jr0Hu8dFfmKQxTHRr/wFCiEI3/n0K6z6WT4gdvMNrmQ=; b=eYcHH6tAld2BgCPo9xFGCot8GuhFOnChV+/UXYaR3yf12aualeH7XhRkSW+A+YyTGJ 5Ry8CSs3/NY8iqVGAWQxzBOp8jXEvFcaBHKvpNH72DJtBOoMxom8GQyXxUBDO28z9ja8 usOy+YQAjXpeyY3TlNz6Plg0ctCq77bbWq/69iSw8H3lyOgb2KXPNUyQKvJXMscDD/8q kMVEJzDc6nS2Pxy1AjYVjtWGl2RsJFlnxO/p/ivf+Mh44qDl/ncjLhe9SGzoEAHH75/A 4sH8PSbvCIdFPl2N+TLco7lam/p1KuHdEmhXwrxzF8v+zkMAhjMO5wE1X0qcTpDujVgG uGwg== MIME-Version: 1.0 In-Reply-To: References: <50ceb674$0$29868$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 17 Dec 2012 11:17:16 +0100 Subject: Re: Unicode From: Anatoli Hristov To: Vlastimil Brom Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1355739439 news.xs4all.nl 6960 [2001:888:2000:d::a6]:55908 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34969 > if you only see encoding problems on printing results to your > terminal, its settings or unicode capability might be the cause, > however, if you also get badly encoding items in the database, you are > likely using an inappropriate encoding in some step. I get badly encoding into my DB > you seem to be doing something like the following (explicitly or > partly implicitly, based on your system defaults): > >>>> print u"=C3=A9troits, en utilisant un portable extr=C3=AAmement puissa= nt".encode("utf-8").decode("windows-1252") > =C3=83=C2=A9troits, en utilisant un portable extr=C3=83=C2=AAmement puiss= ant >>>> > > i.e. encode a text using utf-8 and handling it like windows-1252 > afterwards (or take an already encoded text and decode it with the > inappropriate ANSI encoding. Thank you Vlastimil, I tried to print it as you sholed mr, but I receive an erro: >>> print u"=C3=A9troits, en utilisant un portable extr=C3=AAmement puissan= t".encode("utf-8").decode("windows-1252") Traceback (most recent call last): File "", line 1, in ? UnicodeEncodeError: 'latin-1' codec can't encode character u'\u0192' in position 1: ordinal not in range(256) >>>