Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'subject:Python': 0.06; 'utf-8': 0.07; 'string': 0.09; 'arguments': 0.09; 'bytes.': 0.09; 'imply': 0.09; 'raises': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; "wouldn't": 0.14; 'anyhow,': 0.16; 'learnt': 0.16; 'link,': 0.16; 'parts,': 0.16; 'subject:Could': 0.16; 'subject:Unicode': 0.16; 'unicode.': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'obviously': 0.18; 'pointed': 0.19; 'seems': 0.21; '>>>': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'url:dev': 0.24; "haven't": 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'references': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; 'though.': 0.31; 'interface': 0.32; 'subject:the': 0.34; 'could': 0.34; 'received:google.com': 0.35; 'subject:List': 0.36; 'subject:?': 0.36; 'list': 0.37; 'issue': 0.38; 'fact': 0.38; 'does': 0.39; 'url:2012': 0.39; 'either': 0.39; 'how': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'read': 0.60; 'august': 0.61; 'eye': 0.61; 'length': 0.61; 'mentioned': 0.61; 'matter': 0.61; "you're": 0.61; 'therefore,': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'six': 0.68; 'combining': 0.68; 'article': 0.77; 'url:wordpress': 0.78; 'counts': 0.83; 'subject:this': 0.83; 'characters,': 0.84; 'subject:you': 0.87; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=uLNqpezp/Und73sDxux8wFUXITTQVJRsN39VkfVILPE=; b=jwQRPyRuMQsWb4+/sh6qLe6Q380c7h1jvqDwnGDi9+cn9M/aSBYUGOkhzZEiD2vlME KocCGcYuncBOhIPuyAxffVA1bIQ339Qe/Cl6HlwSmm+32dSGt+txT7rNAd3JSWQudAne VpHvIAdZXse7Q+9CDWQ5tZsdaWbJTDgld0g70zbGDu0aGwHX9SDvVoxlNWxlQd/Gx7Mz e+LrmX4//M6/7qD/S+lcerghdbrHV/3cP/Zszvf+m7ZXMy0ZgYKTsBzOLZZNuWysBemW jNjwCMPSpGHXQ9ZwtwOLCRClw+fXxYxQToNm0xAwsd9onGi6o0DWLqE8dQHxruxjbzU2 juPg== X-Received: by 10.152.19.70 with SMTP id c6mr9437567lae.25.1376214923938; Sun, 11 Aug 2013 02:55:23 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: References: From: Joshua Landau Date: Sun, 11 Aug 2013 10:54:43 +0100 X-Google-Sender-Auth: ITSRYSNmGqPYRuEyWBM99QPbFtw Subject: Re: Could you verify this, Oh Great Unicode Experts of the Python-List? To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376214926 news.xs4all.nl 15926 [2001:888:2000:d::a6]:49744 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52376 On 11 August 2013 07:24, Chris Angelico wrote: > On Sun, Aug 11, 2013 at 7:17 AM, Joshua Landau wrote: >> Given tweet =3D b"caf\x65\xCC\x81".decode(): >> >> >>> tweet >> 'caf=C3=A9' >> >> But: >> >> >>> len(tweet) >> 5 > > You're now looking at the difference between glyphs and combining > characters. Twitter counts combining characters, so when you build one > "thing" out of lots of separately-typed parts, it does count as more > characters. @https://dev.twitter.com/docs/counting-characters#Definition_of_a_Character > The "caf=C3=A9" issue mentioned above raises the question of how you coun= t > the characters in the Tweet string "caf=C3=A9". To the human eye the leng= th is > clearly four characters. Depending on how the data is represented this > could be either five or six UTF-8 bytes. Twitter does not want to penaliz= e > a user for the fact we use UTF-8 or for the fact that the API client in > question used the longer representation. Therefore, Twitter does count > "caf=C3=A9" as four characters no matter which representation is sent. Which would imply that twitter doesn't count combining characters, even though the web interface seems to. > Read this article for some arguments on the subject, including a > number of references to Twitter itself: > > http://unspecified.wordpress.com/2012/04/19/the-importance-of-language-le= vel-abstract-unicode-strings/ I read that *last* time you pointed it out :P. It's a good link, though. -- Anyhow, it's good to know I haven't been obviously stupid with my understanding of Unicode. I learnt it all from this list anyway; wouldn't want to disappoint!