In my app, I generate a UTF8-encoded CSV file with CHCSVWriter and display it using QLPreviewController. The file may have some special characters, such as umlauts (ü, ä), and I have checked the files and they are being generated properly. However when they are displayed with QLPreviewController, the characters are screwed up! I have checked my encodings throughout, and they are all UTF-8, so the code points are not being corrupted. Is there a problem with QLPreviewController? Any suggestions?
Here is the code I am using to create and display the CSV file:
NSString *path = @"my path";
CHCSVWriter *csvWriter = [[CHCSVWriter alloc] initWithCSVFile:path atomic:NO];
csvWriter.encoding = NSUTF8StringEncoding;
NSDictionary* w;
for (w in items) {
[csvWriter writeField:[w valueForKey:@"a"]];
[csvWriter writeField:[w valueForKey:@"b"]];
[csvWriter writeLine];
}
[csvWriter closeFile];
[csvWriter release];
QLPreviewController *ql = [[QLPreviewController alloc] init];
[ql setDataSource:self];
[self presentModalViewController:ql animated:YES];
[ql release];
And here is what is being displayed: