Characters permitted in file names

  • Follow


Is anyone able to let me have a list of the ASCII characters which are not
permitted as a file name in a POSIX conforming system?  (In particular, are
? and ! permitted?).

Chris.


-- 
To reply by e-mail, remove the "--nospam--" in the address
0
Reply Chris 9/7/2003 6:46:26 PM

Chris Vine <chris@cvine--nospam--.freeserve.co.uk> writes:

> Is anyone able to let me have a list of the ASCII characters which
> are not permitted as a file name in a POSIX conforming system?  (In
> particular, are ? and ! permitted?).

The only characters excluded from filenames in POSIX/SUS are slash and
null. See 

http://www.unix.org/single_unix_specification/

under "Base Definitions" look for "Filenames"

Joe
0
Reply Joe 9/7/2003 7:21:00 PM


Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
>Is anyone able to let me have a list of the ASCII characters which are not
>permitted as a file name in a POSIX conforming system?  (In particular, are
>? and ! permitted?).
>
>Chris.

They are permitted (if I remember right, '/' is the only character
not permitted).

Execute the following list of commands in that order, and you'll see.
Note that making odd filename can sometimes be easier than deleting odd
filenames, hence what I've done here is put them all in an otherwise
empty directory and then just delete the entire directory, files and all.

  cd
  mkdir tst
  cd tst
  touch *
  touch ?
  touch !
  ls -l
  cd ..
  rm -rf tst


However, that doesn't mean they should ever be used.  I'm not
sure what POSIX defines, but the Single Unix Specification
Version 3 defines a "Portable Filename Character Set", as the
following,

   "Portable Filename Character Set

   The set of characters from which portable filenames are
   constructed.

      A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
      a b c d e f g h i j k l m n o p q r s t u v w x y z
      0 1 2 3 4 5 6 7 8 9 . _ -


   The last three characters are the period, underscore, and
   hyphen characters, respectively."

        http://www.UNIX-systems.org/single_unix_specification/

By using only those characters you can assure that porting your
filenames to multiple platforms will be less likely to encounter
problems.

-- 
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com
0
Reply Floyd 9/7/2003 8:08:55 PM

Joe Halpin <jhalpin@nortelnetworks.com_.nospam> wrote:
> Chris Vine <chris@cvine--nospam--.freeserve.co.uk> writes:
>> Is anyone able to let me have a list of the ASCII characters which
>> are not permitted as a file name in a POSIX conforming system?  (In
>> particular, are ? and ! permitted?).
>
> The only characters excluded from filenames in POSIX/SUS are slash and
> null. See 
>
> http://www.unix.org/single_unix_specification/
>
> under "Base Definitions" look for "Filenames"

Just out of curiosity, suppose a platform used UTF-8 and one of the bytes in
a multi-byte sequence was '/'. What then? Would it be fine if all of the
interfaces expected UTF-8? And so then it is never wise, from a POSIX
perspective, to inspect a path on its own w/o first using the API to pick
out each file name individually? Where/when does the wide-character
interfaces come into play?

Just curious... ;) Is there a site anywhere that discusses there i18n
issues? I haven't been able to find any.

TIA,

- Bill
0
Reply William 9/7/2003 8:48:23 PM

"Floyd Davidson" <floyd@barrow.com> wrote in message
news:87y8x0nyy0.fld@barrow.com...
> Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
> >Is anyone able to let me have a list of the ASCII characters which are
not
> >permitted as a file name in a POSIX conforming system?  (In particular,
are
> >? and ! permitted?).
> >
> >Chris.
>
> They are permitted (if I remember right, '/' is the only character
> not permitted).
>

    Plus the NULL-byte.  But some may not be as easy as others to use in
creating files and others offer special challenges to command-line
utilities.

            Norm


0
Reply Norm 9/7/2003 10:29:10 PM

"Norm Dresner" <ndrez@att.net> wrote:
>"Floyd Davidson" <floyd@barrow.com> wrote in message
>news:87y8x0nyy0.fld@barrow.com...
>> Chris Vine <chris@cvine--nospam--.freeserve.co.uk> wrote:
>> >Is anyone able to let me have a list of the ASCII characters which are
>not
>> >permitted as a file name in a POSIX conforming system?  (In particular,
>are
>> >? and ! permitted?).
>> >
>> >Chris.
>>
>> They are permitted (if I remember right, '/' is the only character
>> not permitted).
>>
>
>    Plus the NULL-byte.  But some may not be as easy as others to use in
>creating files and others offer special challenges to command-line
>utilities.
>
>            Norm

What's the point of clipping 3/4 of what I said and then repeating it
as if I hadn't said it?

-- 
Floyd L. Davidson           <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska)                         floyd@barrow.com
0
Reply Floyd 9/7/2003 10:53:42 PM

William Ahern <william@wilbur.25thandClement.com> writes:

> Joe Halpin <jhalpin@nortelnetworks.com_.nospam> wrote:
> > Chris Vine <chris@cvine--nospam--.freeserve.co.uk> writes:
> >> Is anyone able to let me have a list of the ASCII characters
> >> which are not permitted as a file name in a POSIX conforming
> >> system?  (In particular, are ? and ! permitted?).
> >
> > The only characters excluded from filenames in POSIX/SUS are slash
> > and null. See
> >
> > http://www.unix.org/single_unix_specification/
> >
> > under "Base Definitions" look for "Filenames"
> 
> Just out of curiosity, suppose a platform used UTF-8 and one of the
> bytes in a multi-byte sequence was '/'. What then?

As I understand it, whatever locale is in force would be allowed to
use anything except characters that resolved to '/' or '\0'.

> Just curious... ;) Is there a site anywhere that discusses there
> i18n issues? I haven't been able to find any.

The complete spec is available through the link I gave above. 

Internationalization isn't my strong suit, but I'm pretty sure that a
character is defined as whatever the locale defines it as, so that if
'/' winds up being a two-byte character in locale X, then it's
disallowed just like it is in the "C" locale.

Joe
0
Reply joe 9/7/2003 11:42:20 PM

Chris Vine wrote:

> Is anyone able to let me have a list of the ASCII characters which are not
> permitted as a file name in a POSIX conforming system?  (In particular,
> are ? and ! permitted?).
> 
> Chris.
> 
> 

Thanks for all the responses to my question.  They told me just what I
wanted.

Chris.

-- 
To reply by e-mail, remove the "--nospam--" in the address
0
Reply Chris 9/8/2003 9:32:01 PM

7 Replies
494 Views

(page loaded in 0.115 seconds)

Similiar Articles:













7/23/2012 9:38:59 PM


Reply: