Re: Encoding to use for file names
Re: Encoding to use for file names
- Subject: Re: Encoding to use for file names
- From: Douglas Davidson <email@hidden>
- Date: Thu, 5 Feb 2009 09:42:36 -0800
On Feb 5, 2009, at 9:33 AM, David Springer wrote:
I generally use UTF8.
On Thu, Feb 5, 2009 at 10:29 AM, Francis Devereux
<email@hidden> wrote:
Hi,
I am porting an app to Mac OS X (well, actually someone else has
ported it
and I am building a cocoa GUI).
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?
The POSIX layer does indeed use a form of UTF-8, but the correct
answer here is -fileSystemRepresentation or -
getFileSystemRepresentation:maxLength:, which insulate you from the
need to hard-code the encoding.
Also noted in the reference for this method: "To convert a char *
path (such as you might get from a C library routine) to an NSString
object, use NSFileManager‘s stringWithFileSystemRepresentation:length:
method."
Douglas Davidson
_______________________________________________
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