Alex Rivera | Logout

_wfopen equivalent under Mac OS X

Asked 2008-08-15T14:59:11.653
18

I'm looking to the equivalent of Windows _wfopen() under Mac OS X. Any idea?

I need this in order to port a Windows library that uses wchar* for its File interface. As this is intended to be a cross-platform library, I am unable to rely on how the client application will get the file path and give it to the library.

Edit
Report

1 Answer

0

If you're using Cocoa it's fairly easy with NSString. Just load the UTF16 data in using -initWithBytes:length:encoding: (or perhaps -initWithCString:encoding:) and then get a UTF8 version by calling UTF8String on the result. Then, just call fopen with your new UTF8 string as the param.

You can definitely call fopen with a UTF-8 string, regardless of language - can't help with C++ on OSX though - sorry.

answered 2008-08-15T15:26:26.920

Your Answer