6

Is there a list of characters which are not allowed in filenames and paths on OS X?

1

3 Answers 3

5

? is allowed.

Only 0x00 (NUL) and : are forbidden for HFS+.

: however is switched in POSIX-based software to /:

alt text alt text

Thanks to Graham Lee who corrected me on this!

1
  • 4
    Actually ':' is forbidden in HFS+, but '/' is forbidden in the POSIX library. So Mac OS X virtual filesystem accepts ':', rejects '/', but has to switch them around when dealing with HFS+. It's quite confusing :).
    – user135
    Oct 28, 2010 at 13:33
4

As Daniel Beck said, NUL and ":" (aka "/" in POSIX contexts) are forbidden; however, it's more complicated than that. HFS+ filenames must be stored in UTF-8 format, in fully decomposed form, with composing characters stored in canonical order (see tn1150). So the answer to your question depends on what you mean by "character":

If you're interested in the sequence of bytes that make up filenames, any sequence that isn't valid UTF-8 (or not properly decomposed) is forbidden.

If you mean unicode code points, that decomposition rule still forbids any point that represents an accented character (it must be stored instead as the base letter + combining accents) (see tn1150table).

3
  • 1
    This answer is misleading. On disk, HFS+ file names are stored as UTF-16, not UTF-8. May 12, 2012 at 2:23
  • 1
    Also ':' characters are swapped with '/'. However, you don't really need to know any of this; the on disk implementation is irrelevant. All POSIX calls into and out of the Kernel use UTF-8 and in that context '/' is a path separator and ':' is allowed and it doesn't have to be decomposed. May 12, 2012 at 2:34
  • 1
    The filenames are not fully decomposed (NFD) either. HFS+ uses a variant of NFD where some characters are in composed form (see Text Encodings in VFS and this answer).
    – Lri
    Jun 4, 2013 at 13:28
1

According to wikipedia, http://en.wikipedia.org/wiki/HFS_Plus any unicode character is allowed, including NUL. But many applications will impose restrictions of their own, such as '/' and so on.

1
  • 1
    This does not fully answer the question like the other answers did. The file system may very well support every character, but the OS layer is more complicated. See Gordon's and Daniel's answers.
    – slhck
    Sep 14, 2014 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.