Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'broken': 0.04; 'encoding': 0.05; 'subject:text': 0.05; 'memory.': 0.07; 'remaining': 0.07; 'utf-8': 0.07; '"if': 0.09; 'bytes,': 0.09; 'friday,': 0.09; 'strings.': 0.09; 'whichever': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; '"keep': 0.16; 'argument,': 0.16; 'forward:': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'mandate': 0.16; 'ought': 0.16; 'sake,': 0.16; 'somehow,': 0.16; 'variants': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'stack': 0.19; 'example': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'bytes': 0.24; 'unicode': 0.24; 'cc:2**0': 0.24; 'right.': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'unix': 0.29; 'change,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'argue': 0.31; "d'aprano": 0.31; 'flags': 0.31; 'ones.': 0.31; 'steven': 0.31; 'anyone': 0.31; 'file': 0.32; 'mac': 0.33; 'trouble': 0.34; "i'd": 0.34; "can't": 0.35; 'agree': 0.35; 'display': 0.35; 'tool': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'scheme': 0.36; 'transition': 0.36; 'done': 0.36; 'doing': 0.36; 'possible': 0.36; 'should': 0.36; 'two': 0.37; 'area': 0.37; 'system,': 0.38; 'massive': 0.38; 'requiring': 0.38; 'somebody': 0.38; 'skip:p 20': 0.39; 'affect': 0.61; 'conversion': 0.61; 'march': 0.61; 'entire': 0.61; 'become': 0.64; 'afraid': 0.65; 'situation': 0.65; 'mar': 0.68; 'policy.': 0.68; 'bulk': 0.74; 'dollar': 0.74; 'day': 0.76; '"yes,': 0.84; '2015': 0.84; 'everything,': 0.84; 'fer': 0.84; 'upwards': 0.84; 'viable': 0.84; 'adopt': 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=sFDUtWezFyPsoju7j1EUDeb283NMyeB4xVX18VG8kDU=; b=x/5yu0t4w/2zmJwIJUqNgxCwqztq8sORwHsD6kqeUMWe3/77wRST2kZ4HMJQp8ucQS y3Poie9pxF0kvUAqgI/TuQeQMmp0IofTnj3cAHoC2TncxjF8brf/8nLFcT0tqZvTe1u+ o7eKaCB1YxXXDLO6NZsjEMVxxKa8tPES3Jv4Zs6pvo3Q/46CxwnjEX5Cp7In+fW59Kwv pgdvxH456c68JP82Y5FTFhwW2192X8lfnaWc2C3jwx3osSQpTlwlLlCHHTB9xrl+cHyA /A+CD9TEK/j09VQzLIVmyH3CJx9xk1KYHWaMzyvDdYXvFQWlNR3AAGyAb/+PgO4WcZ4t edAg== MIME-Version: 1.0 X-Received: by 10.50.62.110 with SMTP id x14mr55599054igr.2.1425655642722; Fri, 06 Mar 2015 07:27:22 -0800 (PST) In-Reply-To: <54f9bea1$0$12994$c3e8da3$5496439d@news.astraweb.com> References: <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> <54f9bea1$0$12994$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 7 Mar 2015 02:27:22 +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: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425655645 news.xs4all.nl 2943 [2001:888:2000:d::a6]:54282 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87027 On Sat, Mar 7, 2015 at 1:50 AM, Steven D'Aprano wrote: > Rustom Mody wrote: > >> On Friday, March 6, 2015 at 10:50:35 AM UTC+5:30, Chris Angelico wrote: > > [snip example of an analogous situation with NULs] > >> Strawman. > > Sigh. If I had a dollar for every time somebody cried "Strawman!" when what > they really should say is "Yes, that's a good argument, I'm afraid I can't > argue against it, at least not without considerable thought", I'd be a > wealthy man... If I had a dollar for every time anyone said "If I had for every time...", I'd go meta all day long and profit from it... :) > - If you are writing your own file system layer, it's 2015 fer fecks sake, > file names should be Unicode strings, not bytes! (That's one part of the > Unix model that needs to die.) You can use UTF-8 or UTF-16 in the file > system, whichever you please, but again remember that both are > variable-width formats. I agree that that part of the Unix model needs to change, but there are two viable ways to move forward: 1) Keep file names as bytes, but mandate that they be valid UTF-8 streams, and recommend that they be decoded UTF-8 for display to a human 2) Change the entire protocol stack from the file system upwards so that file names become Unicode strings. Trouble with #2 is that file names need to be passed around somehow, which means bytes in memory. So ultimately, #2 really means "keep file names as bytes, and mandate an encoding all the way up the stack"... so it's a massive documentation change that really comes down to the same thing as #1. This is one area where, as I understand it, Mac OS got it right. It's time for other Unix variants to adopt the same policy. The bulk of file names will be ASCII-only anyway, so requiring UTF-8 won't affect them; a lot of others are already UTF-8; so all we need is a transition scheme for the remaining ones. If there's a known FS encoding, it ought to be possible to have a file system conversion tool that goes through everything, decodes, re-encodes UTF-8, and then flags the file system as UTF-8 compliant. All that'd be left would be the file names that are broken already - ones that don't decode in the FS encoding - and there's nothing to be done with them but wrap them up into something probably-meaningless-but reversible. When can we start doing this? ext5? ChrisA