Re: normalizing filenames and strings



On 3/28/07, Xavier Bestel <xavier bestel free fr> wrote:
Le mercredi 28 mars 2007 à 21:40 +0200, Denis Jacquerye a écrit :
> On 3/28/07, Alexander Larsson <alexl redhat com> wrote:
> > On Wed, 2007-03-28 at 19:43 +0200, Denis Jacquerye wrote:
> > > On 3/28/07, Alexander Larsson <alexl redhat com> wrote:
> > > > On Wed, 2007-03-28 at 11:50 -0500, Shaun McCance wrote:
> > > > > On Wed, 2007-03-28 at 16:55 +0200, Xavier Bestel wrote:
> > > > > Most applications that operate on files will accept file name
> > > > > arguments when invoked.  What are we supposed to do with these?
> > > > > Bear in mind that the argument isn't only used by shell junkies.
> > > > > It's also used when, for example, you double-click a JPG to open
> > > > > EOG.  Nautilus passes the file name to EOG.
> > > > >
> > > > > If we don't normalize, users might have a hard time opening
> > > > > files from the command line.
> > > >
> > > > Filenames on disk can *never* *ever* be changed. They are byte strings
> > > > and must be treated as such, otherwise you can't open or operate on the
> > > > file they reference.
> > > >
> > > > However, when creating a *new* file, given a utf8 string as filename, we
> > > > can normalize it before creating the file.
> > >
> > > For command line or invoked name, applications could test for the
> > > requested name; if inexistant, they should attempt with the
> > > canonically equivalent filenames existing.
> >
> > No, its never right to guess like this. It can lead to all sorts of
> > problems, and it is a performance drag. File names are exact
> > identifiers, not UI strings.
>
> So how should it be done? If I have a file "é" (precomposed) and I
> type "é" (composed), how is the existing file going to be opened?

You don't. Command-line applications don't second-guess their target.

Interestingly enough Mac OS X normalizes (NFD) at the filesystem level.
http://developer.apple.com/qa/qa2001/qa1235.html

Denis Moyogo Jacquerye


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]