Hi there,
In my iPhone App I have the capability to export data to an .txt file and send it via Mail – but have currently problems regarding the encoding.
To attach the file to mail I simply create a NSData instance from a NSString instance as followed:
NSData *dataToExport = [[NSData alloc] initWithData:[myExportString dataUsingEncoding:NSUTF8StringEncoding]];
[[NSFileManager defaultManager] createFileAtPath:pathToExportFile contents:dataToExport attributes:nil];
But this finally results in a file with content like that (wrong encoding):
√úberraschung
Instead using
[myExportString writeToFile:pathToExportFile atomically:NO encoding:NSUTF8StringEncoding error:&error];
... creates a file with the correct enconding:
Überraschung
Any ideas, how I'm able to get the right encoding with the first way?
Thank you, Florian