I'm fetching JSON objects and saving them in NSString as follows:
// fetch JSON from a Wiki article
NSError *error = nil;
NSString *responseString = [NSString stringWithContentsOfURL:myURL encoding:NSUTF8StringEncoding error:&error];
This is working in general but my responseString is full of \u####
escape characters, what I want is the corresponding UTF8 characters, e.g. \u2640
should be ♀
.
What's the easiest way to decode all escape characters in my responseString
?
UPDATE:
I read somewhere that I should try fetching the JSON with NSNonLossyASCIIStringEncoding
instead of NSUTF8StringEncoding
, but this lead to an error so I didn't get a responseString
at all with this.
The error then is:
Error Domain=NSCocoaErrorDomain Code=261 "The operation couldn’t be completed. (Cocoa error 261.)"