Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'output': 0.04; '(python': 0.05; 'say,': 0.05; 'ascii': 0.07; 'utf-8': 0.07; 'scripts': 0.09; 'subject:How': 0.09; 'python': 0.09; 'encode': 0.09; 'subject:()': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'aug': 0.13; 'cases': 0.15; 'encoding': 0.15; '(eg.': 0.16; 'circumvent': 0.16; 'codec': 0.16; 'cp1252': 0.16; 'encodings': 0.16; 'for,': 0.16; 'jerry': 0.16; 'ordinal': 0.16; 'subject:unicode': 0.16; 'subject:variable': 0.16; 'wrote:': 0.17; 'unicode': 0.17; 'obviously': 0.18; 'sort': 0.21; '"",': 0.22; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'coding': 0.27; 'older': 0.27; 'message-id:@mail.gmail.com': 0.27; 'skip:( 20': 0.28; 'all.': 0.28; '>>>>': 0.29; 'served': 0.29; 'character': 0.29; 'definition': 0.29; 'this.': 0.29; 'fri,': 0.30; 'file': 0.32; 'received:209.85.160.46': 0.32; "skip:' 20": 0.32; 'could': 0.32; 'european': 0.33; 'legacy': 0.33; 'traceback': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'text': 0.34; 'exist': 0.35; 'moved': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'apple': 0.36; 'characters': 0.36; 'should': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'called': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'easy': 0.60; 'skip:u 10': 0.60; 'real': 0.61; 'french': 0.64; 'user,': 0.69; '21st': 0.75; '100%': 0.76; 'products,': 0.78; 'century,': 0.84; 'subject:value': 0.84 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=LDCNilM01EN4WddmP80L4/fY0hFTg1j9jBTzcWaOHO8=; b=eOJLRo2oTTBhPRhllW9opBr6H26UZQ6HSGUQIEqsm7ed+zWPqywgUUdNMNMC7y4VLF oHes87jZwKa9mzXEMntumW/w4vljM6BC1rLoag7ggt7PJj8wqrMaIUQC5YuhEBtbPXi4 Zn0q+PZs+5nWH8egaEk+QtbB8Cnw09CdKH5OioseByxXunFdxpdQL3Oza8spWQlaCH3y czeHsvlRouHBGbWvGhLTirl8+Fj+qvyXb0t95mRE3A4crpmh41UY7MtanlshBlh3/0Dk Nweyk+mdu93MT2tZQZTKkLSJqSAOIQ1nxYRluXZl4IARSF86l6CMQFaezAg9ZYClKrfL 6SEQ== MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 17 Aug 2012 14:21:34 -0400 Subject: Re: How do I display unicode value stored in a string variable using ord() From: Jerry Hill 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.12 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: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345227697 news.xs4all.nl 6980 [2001:888:2000:d::a6]:44237 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27254 On Fri, Aug 17, 2012 at 1:49 PM, wrote: > The character '=E2=80=A6', Unicode name 'HORIZONTAL ELLIPSIS', > is one of these characters existing in the cp1252, mac-roman > coding schemes and not in iso-8859-1 (latin-1) and obviously > not in ascii. It causes Py3.3 to work a few 100% slower > than Py<3.3 versions due to the flexible string representation > (ascii/latin-1/ucs-2/ucs-4) (I found cases up to 1000%). > >>>> '=E2=80=A6'.encode('cp1252') > b'\x85' >>>> '=E2=80=A6'.encode('mac-roman') > b'\xc9' >>>> '=E2=80=A6'.encode('iso-8859-1') # latin-1 > Traceback (most recent call last): > File "", line 1, in > UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026' > in position 0: ordinal not in range(256) > > If one could neglect this (typographically important) glyph, what > to say about the characters of the European scripts (languages) > present in cp1252 or in mac-roman but not in latin-1 (eg. the > French script/language)? So... python should change the longstanding definition of the latin-1 character set? This isn't some sort of python limitation, it's just the reality of legacy encodings that actually exist in the real world. > Very nice. Python 2 was built for ascii user, now Python 3 is > *optimized* for, let say, ascii user! > > The future is bright for Python. French users are better > served with Apple or MS products, simply because these > corporates know you can not write French with iso-8859-1. > > PS When "TeX" moved from the ascii encoding to iso-8859-1 > and the so called Cork encoding, "they" know this and provided > all the complementary packages to circumvent this. It was > in 199? (Python was not even born). > > Ditto for the foundries (Adobe, Linotype, ...) I don't understand what any of this has to do with Python. Just output your text in UTF-8 like any civilized person in the 21st century, and none of that is a problem at all. Python make that easy. It also makes it easy to interoperate with older encodings if you have to. --=20 Jerry