On 5 Feb 2009, at 17:40, Joar Wingfors wrote:

On Feb 5, 2009, at 9:29 AM, Francis Devereux wrote:

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 correct thing to do would be to use:

        -[NSString fileSystemRepresentation]

<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/fileSystemRepresentation >

[NSString fileSystemRepresentation] works great, thanks to all who replied.

Francis
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to