Hello everybody,
My problem is the following.
In my app I need to save text files and this should also work for chinese text.
To do that I save the text file making use of NSUTF8StringEncoding with the following instruction:
[gameFile writeToFile:_path atomically:YES encoding:NSUTF8StringEncoding error:&error];
This works fine!
The problem is when I have to read the file. I don't read the file completely but I scan each line and I read each line using NSUTF8StringEncoding.
If I read a normal file (medium size) all is ok, but if I read a big file (about 9MB) I have the following error:
Error Domain=NSCocoaErrorDomain Code=261 "The file “KingBaseLite.txt” couldn’t be opened using text encoding Unicode (UTF-8)." UserInfo={NSFilePath=/Users/giordanovicoli/Library/Developer/CoreSimulator/Devices/8BEEEF25-620C-4B29-BD4A-E31B3C169E05/data/Containers/Data/Application/D0394678-DCCC-4D3E-8F9F-3B8685C80625/Documents/KingBaseLite.txt, NSStringEncoding=4}
If I read the same file with the following encoding: NSISOLatin1StringEncoding the file is read correctly but with this encoding I am not able to read chinese text.
I hope I was clear in my explanation.
Please, is there someone able to solve this problem?
Many thanks and regards,
Giordano