views:

46

answers:

2

How to read and write an NSString with UTF8N? I use this to load a UTF-8 file and it seems to work with UTF-8N.

NSString *string = [NSString stringWithContentsOfFile:destPath encoding:NSUTF8StringEncoding error:&error];

The problem is when I save the file with

[string writeToFile:tempFile atomically:YES encoding:NSUTF8StringEncoding error:&error];

the file is not readable in a normal text editor on the computer. I can still read the file as a UTF-8 file though.

What am I missing?

A: 

Try to write the string to file without providing any encoding

        [string writeToFile:tempFile atomically:YES];
Anil Sivadas
That method is deprecated, but I suppose it could be useful in tracking down where the error is.
Wevah
That is where I started, but its worth a try I guess.
Kevin
A: 

A bunch of guess and check found NSShiftJISStringEncoding did the trick.

Kevin