Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'subject: -- ': 0.07; 'string': 0.09; 'methods,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tests,': 0.09; '~ethan~': 0.09; 'python': 0.11; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Unicode': 0.16; 'subject:handling': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'first.': 0.19; 'tests': 0.22; 'header:User-Agent:1': 0.23; 'example.': 0.24; 'passes': 0.24; 'unicode': 0.24; '(or': 0.24; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'characters': 0.30; 'code': 0.31; 'correctly.': 0.31; "d'aprano": 0.31; 'post.': 0.31; 'steven': 0.31; 'knowledge': 0.35; "can't": 0.35; 'case,': 0.35; 'operate': 0.35; 'but': 0.35; 'doing': 0.36; 'thanks': 0.36; "i'll": 0.36; 'should': 0.36; 'being': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'failures': 0.60; "you'll": 0.62; 'more': 0.64; 'specialized': 0.65; 'believe': 0.68; 'ethan': 0.84; 'furman': 0.84; 'is)': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: Python Unicode handling wins again -- mostly Date: Mon, 02 Dec 2013 16:14:13 -0500 References: <529934dc$0$29993$c3e8da3$5496439d@news.astraweb.com> <529CEFB1.2030007@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 18.189.39.242 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 In-Reply-To: <529CEFB1.2030007@stoneleaf.us> 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386018871 news.xs4all.nl 15876 [2001:888:2000:d::a6]:53536 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60884 On 12/2/13 3:38 PM, Ethan Furman wrote: > On 11/29/2013 04:44 PM, Steven D'Aprano wrote: >> >> Out of the nine tests, Python 3.3 passes six, with three tests being >> failures or dubious. If you believe that the native string type should >> operate on code-points, then you'll think that Python does the right >> thing. > > I think Python is doing it correctly. If I want to operate on > "clusters" I'll normalize the string first. > > Thanks for this excellent post. > > -- > ~Ethan~ This is where my knowledge about Unicode gets fuzzy. Isn't it the case that some grapheme clusters (or whatever the right word is) can't be normalized down to a single code point? Characters can accept many accents, for example. In that case, you can't always normalize and use the existing string methods, but would need more specialized code. --Ned.