Reputation: 71008
When I take a path in an NSString
and turn around and use it in a C API, for example:
CGDataProviderRef CGDataProviderCreateWithFilename(const char *filename );
What is the correct encoding for the path when flattening to a char*
? UTF8? (ASCII??)
I feel like this should be either obvious, or obviously documented, but I'm having trouble thinking and/or finding the answer.
Upvotes: 3
Views: 1301
Reputation: 873
an example that worked for me using the above answer
NSString *path =@"/Users/ethansanford/Desktop/mutable string logic/mutable string logic/long-arrow-right.png" ;
CGDataProviderRef provider = CGDataProviderCreateWithFilename(path.fileSystemRepresentation);
imageRef2 =CGImageCreateWithPNGDataProvider(provider, NULL, false, kCGRenderingIntentDefault);
Upvotes: 0