Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.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; 'bits': 0.07; 'character,': 0.07; 'interpreted': 0.07; 'subject:How': 0.09; 'byte,': 0.09; 'bytes,': 0.09; 'pep': 0.09; 'received:mail- lpp01m010-f46.google.com': 0.09; 'subject:()': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'subset': 0.09; 'aug': 0.13; ':-)': 0.13; 'encoding': 0.15; 'sat,': 0.15; '10:17': 0.16; 'format?': 0.16; 'mistake.': 0.16; 'subject:unicode': 0.16; 'subject:variable': 0.16; 'truncating': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'bytes': 0.17; 'refers': 0.17; 'string,': 0.17; 'unicode': 0.17; 'previously': 0.18; 'versions': 0.20; 'equivalent': 0.20; 'bit': 0.21; 'context.': 0.22; 'interpret': 0.22; 'header:In-Reply-To:1': 0.25; 'fit': 0.26; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'finds': 0.29; 'represented': 0.29; 'steven': 0.29; 'character': 0.29; 'received:209.85.215.46': 0.30; 'code': 0.31; 'point': 0.31; 'not.': 0.32; 'point,': 0.33; 'to:addr:python-list': 0.33; 'equal': 0.33; 'point.': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'largest': 0.35; 'pm,': 0.35; 'too.': 0.35; 'received:209.85': 0.35; 'previous': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'talk': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'different': 0.63; 'great': 0.64; 'complaint': 0.84; 'internally.': 0.84; "it'd": 0.84; 'subject:value': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=8HsjCXlRii05uD97HSoaUR1V8tmu+rjeHXUp+iCoZLM=; b=yhUNL3uo0XAHd6epc9Al5haGcPFRiLw1sz4nMXI91LEQRAPBuZjWkgiGyaAMw0ahAl I/0HTqIVKHV2CM8wjYKilGQaBBTXsmSi11QSHoFtCRXpur9hIDjig1BxikOUu7PEw+SF P3dD2R2GvxHcy7tIM55qb26zMXte4pfP3WRSrWjNMpaxeT5dyjUKy+wCCSer+CmW6nAD KKycuQvJn8zNY/JPGL9fAfjlx981dolKM0jZfFtkHyBvsbHl2RA5iTRAogyGmEHy0Igz UmSbO/FWvkWWQ/N4Qge5LEhhMu/wi4q+C/peHGDF1kLZCsu3gBRq8XZDFFAYiEdZmRJY Mo3A== MIME-Version: 1.0 In-Reply-To: References: <253ddd61-4bb5-4f46-b58c-525e55b27558@googlegroups.com> <502EAFB2.7050405@davea.name> <502f15b5$0$29978$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Sat, 18 Aug 2012 09:18:39 -0600 Subject: Re: How do I display unicode value stored in a string variable using ord() To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345303152 news.xs4all.nl 6939 [2001:888:2000:d::a6]:49771 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27297 (Resending this to the list because I previously sent it only to Steven by mistake. Also showing off a case where top-posting is reasonable, since this bit requires no context. :-) On Sat, Aug 18, 2012 at 1:41 AM, Ian Kelly wrote: > > On Aug 17, 2012 10:17 PM, "Steven D'Aprano" > wrote: >> >> Unicode strings are not represented as Latin-1 internally. Latin-1 is a >> byte encoding, not a unicode internal format. Perhaps you mean to say >> that they are represented as a single byte format? > > They are represented as a single-byte format that happens to be equivalent > to Latin-1, because Latin-1 is a proper subset of Unicode; every character > representable in Latin-1 has a byte value equal to its Unicode codepoint. > This talk of whether it's a byte encoding or a 1-byte Unicode representation > is then just semantics. Even the PEP refers to the 1-byte representation as > Latin-1. > >> >> >> I understand the complaint >> >> to be that while the change is great for strings that happen to fit in >> >> Latin-1, it is less efficient than previous versions for strings that >> >> do not. >> > >> > That's not the way I interpreted the PEP 393. It takes a pure unicode >> > string, finds the largest code point in that string, and chooses 1, 2 or >> > 4 bytes for every character, based on how many bits it'd take for that >> > largest code point. >> >> That's how I interpret it too. > > I don't see how this is any different from what I described. Using all 4 > bytes of the code point, you get UCS-4. Truncating to 2 bytes, you get > UCS-2. Truncating to 1 byte, you get Latin-1.