Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'subject: -- ': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'expects': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Unicode': 0.16; 'subject:handling': 0.16; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'string,': 0.24; 'question': 0.24; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'skip:p 30': 0.29; 'gives': 0.31; 'code': 0.31; "d'aprano": 0.31; 'steven': 0.31; '(2)': 0.35; 'operate': 0.35; 'but': 0.35; 'should': 0.36; '(3)': 0.38; '8bit%:86': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'length': 0.61; 'first': 0.61; 'received:46': 0.66; 'reverse': 0.68 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Serhiy Storchaka Subject: Re: Python Unicode handling wins again -- mostly Date: Sun, 01 Dec 2013 20:00:21 +0200 References: <529934dc$0$29993$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 46.211.129.106 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: <529934dc$0$29993$c3e8da3$5496439d@news.astraweb.com> 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: 1385920822 news.xs4all.nl 15994 [2001:888:2000:d::a6]:43204 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60831 30.11.13 02:44, Steven D'Aprano написав(ла): > (2) If you reverse that string, does it give "lëon"? The implication of > this question is that strings should operate on grapheme clusters rather > than code points. Python fails this test: > > py> print("noe\u0308l"[::-1]) > leon >>> print(unicodedata.normalize('NFC', "noe\u0308l")[::-1]) lëon > (3) What are the first three characters? The author suggests that the > answer should be "noë", in which case Python fails again: > > py> print("noe\u0308l"[:3]) > noe >>> print(unicodedata.normalize('NFC', "noe\u0308l")[:3]) noë > (4) Likewise, what is the length of the decomposed string? The author > expects 4, but Python gives 5: > > py> len("noe\u0308l") > 5 >>> print(len(unicodedata.normalize('NFC', "noe\u0308l"))) 4