Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'preferably': 0.05; 'subject:text': 0.05; 'subject:question': 0.10; 'cc:addr:python- list': 0.11; 'added.': 0.16; 'arbitrarily': 0.16; 'backspace': 0.16; 'columns': 0.16; 'disallow': 0.16; 'for,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'limiting': 0.16; 'pathological': 0.16; 'pressing': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'logical': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; 'points': 0.29; 'characters': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'languages': 0.32; 'cases': 0.33; 'display': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'marks': 0.36; 'ones,': 0.36; 'example,': 0.37; 'e.g.': 0.38; 'users': 0.40; 'most': 0.60; 'times': 0.62; "you've": 0.63; 'skip:n 10': 0.64; 'mar': 0.68; 'combining': 0.68; '2015': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=FeLQ5XwFEj3qSBGqsxh0096+jRjmK3Bof1nXGRFh5AA=; b=ApBSnSaegdogdNsE3upXXmXpjPwyjsHhwHINPFAYedK690WO3dAfw5c5lhR/TLKEPy 6QXdCMoBDyf7dQ0rH32XOgnniOxQBt0XZ8eny8NobJdsstm+icHByiCXgGHvHu3Vnmxo XtcTJMND3hzEsbkvt+JmwYbTV7gBLvml5Q5LfIGrOc+ac8KkDEvzKx6j/TEwxnqozxRD c29nO91/bn9n77NkkTfpFm/a7dsjVkS2HhtGMJOF6qp3ZnLZUwNkdyVUDsNDlC12RhHE sbYtOtpptY0freXOrKTL5E3H09lplvni/bIiFRb9el0dLUcnOiPlROG4YzCQVaz3Wdo9 SOJQ== MIME-Version: 1.0 X-Received: by 10.50.79.161 with SMTP id k1mr27714783igx.14.1425649166238; Fri, 06 Mar 2015 05:39:26 -0800 (PST) In-Reply-To: <1425648780.3358976.236451377.1ED1534A@webmail.messagingengine.com> 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> Date: Sat, 7 Mar 2015 00:39:26 +1100 Subject: Re: Newbie question about text encoding From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425649169 news.xs4all.nl 2959 [2001:888:2000:d::a6]:57115 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87021 On Sat, Mar 7, 2015 at 12:33 AM, wrote: > However, when do you _really_ want the number of characters? You may > want to use it for, for example, the number of columns in a 'monospace' > font, which you've already screwed up because you haven't accounted for > double-wide characters or combining marks. Or you may want the position > that pressing an arrow key or backspace or forward-delete a number of > times will reach, which has its own rules in e.g. Indic languages (and > also fails on Latin with combining marks). Number of code points is the most logical way to length-limit something. If you want to allow users to set their display names but not to make arbitrarily long ones, limiting them to X code points is the safest way (and preferably do an NFC or NFD normalization before counting, for consistency); this means you disallow pathological cases where every base character has innumerable combining marks added. ChrisA