Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:text': 0.05; 'string': 0.09; 'strings.': 0.09; 'sure,': 0.09; 'url:unicode': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'discussion.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'invalid.': 0.16; 'sure.': 0.16; 'unicode,': 0.16; 'url:faq': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'bytes': 0.24; 'unicode': 0.24; 'mon,': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'appear': 0.29; 'chris': 0.29; 'leave': 0.29; 'points': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'languages': 0.32; 'beginning': 0.33; 'not.': 0.33; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'url:org': 0.36; 'should': 0.36; 'problems': 0.38; 'pm,': 0.38; 'skip:* 10': 0.61; 'skip:n 10': 0.64; 'total': 0.65; 'mar': 0.68; 'invalid': 0.68; 'containing': 0.69; 'legal': 0.71; 'construction': 0.72; '2015': 0.84; 'mistaken': 0.84; 'notion': 0.91; '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=zqyh/sVEQE69OIRgM3iOFSgkSUQi/j4lCqUhHH+rYQo=; b=A7rKW8ZtkyEPdy/Yhh8FtgL6XaxYni00hdUcgrzsIimhZnV8qShsmTzHhhyy0eemh9 YR7ZpIhJEhI0C5wg5NGqHonasBh3hjRKiMlZkp0FBip7QnMBEQYpyqw+KmLAKryzWJiZ Sdrt6lG+CDtz2HAU2+qlS+geJCyUuSKWBatqy+4MrHCaClMUqk1tOgqG61pCEiEL2xe1 vg7+NONw0FxeJsztg9TJveo8t5XFsp/m242l0ZE12KgdaWQLjohRWsOEtDBXocHv7nkO x6HnZnrjfZQJwB1dAbY9R1z+g+qhlRZuRRpnHDQNp+gwGEWUrYLW1vT5qCAWvwjMuM2a vnVA== MIME-Version: 1.0 X-Received: by 10.42.51.68 with SMTP id d4mr23965385icg.26.1425883494740; Sun, 08 Mar 2015 23:44:54 -0700 (PDT) In-Reply-To: <54fd3f10$0$12977$c3e8da3$5496439d@news.astraweb.com> References: <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> <54fadc70$0$13004$c3e8da3$5496439d@news.astraweb.com> <87twxxxbvd.fsf@elektro.pacujo.net> <54fb1bf4$0$12993$c3e8da3$5496439d@news.astraweb.com> <87twxw4xlz.fsf@elektro.pacujo.net> <54fba9d4$0$12988$c3e8da3$5496439d@news.astraweb.com> <87y4n8uf9a.fsf@elektro.pacujo.net> <87twxvvrjl.fsf@elektro.pacujo.net> <54fc9400$0$13009$c3e8da3$5496439d@news.astraweb.com> <54fd3f10$0$12977$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 9 Mar 2015 17:44:54 +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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425883497 news.xs4all.nl 2857 [2001:888:2000:d::a6]:48568 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87175 On Mon, Mar 9, 2015 at 5:34 PM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> As to the notion of rejecting the construction of strings containing >> these invalid codepoints, I'm not sure. Are there any languages out >> there that have a Unicode string type that requires that all >> codepoints be valid (no surrogates, no U+FFFE, etc)? > > U+FFFE and U+FFFF are *noncharacters*, not invalid. There are a total of 66 > noncharacters in Unicode, and they are legal in strings. > > http://www.unicode.org/faq/private_use.html#nonchar8 > > I think the only illegal code points are surrogates. Surrogates should only > appear as bytes in UTF-16 byte-strings. U+FFFE would cause problems at the beginning of a UTF-16 stream, as it could be mistaken for a BOM - that's why it's a noncharacter. But sure, let's leave them out of the discussion. The question is whether surrogates are legal or not. ChrisA