Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
    
Actually, both : and ? are allowed, I must be having a different problem. –  Paul Biggar Oct 28 '10 at 12:18
    
I'm new to this telepathy thing, so I just answered what you wrote, not what you thought ;-) –  Daniel Beck Oct 28 '10 at 12:38
    
Useful references: Wikipedia article on Filenames and Fixing Unix/Linux/POSIX Filenames. –  Dennis Williamson Oct 29 '10 at 3:21
add comment

2 Answers

up vote 3 down vote accepted

? 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!

share|improve this answer
3  
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 '10 at 13:33
    
@Graham thanks for the clarification. –  Daniel Beck Oct 28 '10 at 13:41
    
no problem. I didn't fully understand it until I read the chapters in Mac OS X Internals about the filesystem implementation :-S. –  user135 Oct 28 '10 at 13:48
add comment

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).

share|improve this answer
1  
This answer is misleading. On disk, HFS+ file names are stored as UTF-16, not UTF-8. –  Chris Suter May 12 '12 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. –  Chris Suter May 12 '12 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 '13 at 13:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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