in reply to Removing Bad Characters from a String

In Unix, there are no "bad characters", except that NUL is interpreted as end-of-string, and "/" is reserved for a directory separator. What precisely are you asking about?

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on Re: Removing Bad Characters from a String

Replies are listed 'Best First'.
Re^2: Removing Bad Characters from a String
by mrborisguy (Hermit) on May 09, 2005 at 01:30 UTC
    unless this is a windows machine, in which case there are more 'bad characters'

    From a windows error message:

    A filename cannot contain any of the following characters:
    / : * ? " < > |

      That's the list for NTFS, in FAT, more characters are banned. On the top of my head, I think the additional ones are \x20 + = [ ] %

      I think that control characters (\x00-\x1f but not \x7f IIRC) and backslash (\\) are also banned in filenames, despite that error message not mentioning them.

        actually, i'm not sure about your assertion that those additional characters are banned in FAT. i'm running on my parents' win 98 machine, which has a FAT filesystem (i first assumed, but then i checked, and it is FAT). i successfully named a file 'a[0] += 7 % 3.txt'. this is also the OS i got my error message from.
        i'd upload a small image as proof, but i'm not really sure how.
        LOL and ++ from me, but it's weird hearing this from one of the co-authors of Learning Perl on Win32 Systems...

        Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

        Don't fool yourself.