_wfopen equivalent under Mac OS X

后端 未结 5 1298
甜味超标
甜味超标 2021-02-07 06:30

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 i

5条回答
  •  后悔当初
    2021-02-07 06:33

    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.

提交回复
热议问题