6
Is there a list of characters which are not allowed in filenames and paths on OS X?
6
Is there a list of characters which are not allowed in filenames and paths on OS X?
5
?
is allowed.
Only 0x00
(NUL
) and :
are forbidden for HFS+.
:
however is switched in POSIX-based software to /
:
Thanks to Graham Lee who corrected me on this!
4Actually ':' 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 :). – None – 2010-10-28T13:33:27.480
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).
1This answer is misleading. On disk, HFS+ file names are stored as UTF-16, not UTF-8. – Chris Suter – 2012-05-12T02:23:35.997
1Also ':' 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. – Chris Suter – 2012-05-12T02:34:06.543
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 – 2013-06-04T13:28:59.6331
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.
1This 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 – 2014-09-14T13:21:30.190
Useful references: Wikipedia article on Filenames and Fixing Unix/Linux/POSIX Filenames.
– Paused until further notice. – 2010-10-29T03:21:46.693