I made multi-language unicode files and tried to use it in my app, but failed.
I tried fgets and fgetws, and saved text file to various encodings(ex: UTF-8, ASCII, Unicode, Unicode(BE)) but no use.
Please tell me how to import unicode text files in iPhone app.
Is there any reason to stick to C API’s?
Also, its tricky to rely on wchar (and wide char functions) for Unicode support on different platforms (you shall be warned about this in Unicode specifications “Section 5.2 of Unicode specifications” http://www.unicode.org/versions/Unicode6.0.0/ch05.pdf).
If reading Unicode is the only concern, you may try this code snippet (assuming your file(inp.rtf) is in main resource bundle)
NSString *filePath = [[NSBundle mainBundle] pathForResource:@”inp” ofType:@”rtf”];
NSData *myData = [NSData dataWithContentsOfFile:filePath];
if (myData) {
NSString *str = [[NSString alloc] initWithData:myData encoding:NSUnicodeStringEncoding];
}
You may replace “NSUnicodeStringEncoding” with the suitable encoding.