Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:text': 0.05; 'reject': 0.07; 'utf-8': 0.07; 'received:internal': 0.09; 'subject:question': 0.10; 'length,': 0.16; 'limiting': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.44': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:compute4.internal': 0.16; 'received:messagingengine.com': 0.16; 'simple.': 0.16; 'truncate': 0.16; 'username.': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'putting': 0.22; 'bytes': 0.24; 'unicode': 0.24; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'character': 0.29; "doesn't": 0.30; 'code': 0.31; 'that.': 0.31; 'fri,': 0.33; 'received:66': 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'received:10': 0.37; 'problems': 0.38; 'to:addr:python- list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'called': 0.40; 'then,': 0.60; 'units': 0.60; 'from:no real name:2**0': 0.61; 'entire': 0.61; 'first': 0.61; 'save': 0.62; "you've": 0.63; 'header:Message-Id:1': 0.63; 'mar': 0.68; 'combining': 0.68; 'from.': 0.93 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=mesmtp; bh=MNu0s3M6iPT30TTIWrNyRSDACkk=; b=i3sp vwU0sgj6Fi6Jsc5JxhJCsHYFThjxowdHu+EWv0i6Io9iLIZTJAMRgZVIrfHEMiuQ 2DPnBwgfrPUBuWvcb4yhSNOciVcChgf8jm9aZsqj7fUyACh/B5ZPV6wivG9+R4V4 amesxxIkOKx/kqXUUNPZ7elhzmz3qtwxNs+0PYc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:in-reply-to :references:subject:date; s=smtpout; bh=MNu0s3M6iPT30TTIWrNyRSDA Ckk=; b=c2EmVTSNVRiJLmEC7p29+83EuHAlJ+EJZbZsdgkzpKGg0fkrUuazX6Av MTwRl4JAbJqC2ij+8vsGLJvr1VWIWhvdg5SWyrFsaofNFUUjzFFQChzQhkYJ7zpj Phqu1WGAPrShrWaD6bdeelGcC8yceiRB9DKsxOR5jsk4zfWERLo= X-Sasl-Enc: iL2zQCoVJpsNfo2a6Gm6x1vGqtvOqy37cn36VlcIYcZU 1425652062 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-07699171 In-Reply-To: References: <201502241524.t1OFO09k022270@fido.openend.se> <201502241620.t1OGKf4n002146@fido.openend.se> <54ECB134.5090304@davea.name> <201502241945.t1OJjshO013092@fido.openend.se> <201502241957.t1OJvrJS015604@fido.openend.se> <9169f3b1-2ac7-42a3-8033-584f84b88a1f@googlegroups.com> <7a75a23c-4678-4d7a-a2ec-9e8fff4c07f8@googlegroups.com> <132d5ce6-f672-4eec-99f9-1cc9e88b94f3@googlegroups.com> <619e4cb5-1c4c-449b-a5d7-951101b32b45@googlegroups.com> <54f862ca$0$13014$c3e8da3$5496439d@news.astraweb.com> <01dd9b83-db3e-4e7d-9022-dc6af75eb570@googlegroups.com> <1425648780.3358976.236451377.1ED1534A@webmail.messagingengine.com> <1425650591.3368169.236462481.4CA83873@webmail.messagingengine.com> Subject: Re: Newbie question about text encoding Date: Fri, 06 Mar 2015 09:27:42 -0500 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425652066 news.xs4all.nl 2887 [2001:888:2000:d::a6]:45746 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87025 On Fri, Mar 6, 2015, at 09:11, Chris Angelico wrote: > To prevent people from putting three paragraphs of lipsum in and > calling it a username. Limiting by UTF-8 bytes or UTF-16 units works just as well for that. > So you truncate to the desired length, then if the first character of > the trimmed-off section is a combining mark (based on its Unicode > character types), you keep trimming until you've removed a character > which isn't. Then, if you no longer have any content whatsoever, > reject the name. Simple. My entire point was that UTF-32 doesn't save you from that, so it cannot be called a deficiency of UTF-16. My point is there are very few problems to which "count of Unicode code points" is the only right answer - that UTF-32 is good enough for but that are meaningfully impacted by a naive usage of UTF-16, to the point where UTF-16 is something you have to be "safe" from.