Thanks, that sounds like a couple of good options. I'll try some options with the second one, and fall back on the first if necessary.

Alastair Houghton wrote:
My recommendation would be as follows:

1. If possible, don’t base the filename on the user’s input.  Instead, generate 
your own filename (one option might be to use a UUID) and then store a 
dictionary mapping the user’s input to the filename somewhere in your bundle.  
This avoids any problems with filename encoding completely.  You will still 
have to worry about normalising the user’s input, but that’s then just a matter 
of choosing a normalisation.

2. If you must base the filename on user input, do so by stripping out 
non-ASCII characters and replacing them with e.g. ‘_’s.  You’ll also need to 
make sure that the result is unique, otherwise a user might specify two names 
that both map to the same ASCIIfied name.  You’ll still want to store the 
dictionary mapping the user’s input.

The benefit of the second approach is that your bundle is more easily 
understood by a human being.  The downside is that it’s more complicated to 

Both will work, whatever the filesystem is, as they don’t rely on filesystem 
encoding behaviour.

(You might also then ponder whether you want things to be case-sensitive or 
not; the above will be.  Making it not case-sensitive is a little tricky in 
that just converting to upper or lower case doesn’t*quite*  work; the correct 
approach would be to use CFStringFold() to case-fold the string,*after*  
normalising, before using it as a dictionary key.)
John Brownie
In Finland on furlough from SIL Papua New Guinea

Cocoa-dev mailing list (

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)

Help/Unsubscribe/Update your Subscription:

This email sent to

Reply via email to