Re: Encoding to use for file names
Re: Encoding to use for file names
- Subject: Re: Encoding to use for file names
- From: Nick Zitzmann <email@hidden>
- Date: Thu, 5 Feb 2009 10:41:17 -0700
On Feb 5, 2009, at 10:29 AM, Francis Devereux wrote:
I have an NSString with a filename in it that I need to pass to the
portable code as a char *. The portable code will then pass it to
UNIX file handling functions like fopen().
I guess that I need to use NSString's getCString:maxLength:encoding:
method, but what should I pass for the encoding parameter? Phrased
another way, what encoding does fopen() expect filenames to be in?
You guessed incorrectly, actually. Always use -
fileSystemRepresentation or -getFileSystemRepresentation:maxLength:. -
UTF8String will incidentally work for HFS+ and UFS, but it probably
won't work with legacy file systems that don't support Unicode, such
as HFS.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden