Reputation: 919
I have an issue with Json response and accent characters. I have this pice of code;
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSString *responseString = [[NSString alloc] initWithData:self.multipleData encoding:NSASCIIStringEncoding];
NSDictionary *results = [parser objectWithString:responseString ];
I have tried UTF8 encoding, latin encoding, Json native parser, touchJson parser, and best result, I get this values in the NSDictionary values that contain accents:
html = "Ubicado en pleno campo de Barcelona, a 5 minutos del n\U00facleo urbano de la ciudad y a 7 kil\U00f3metros de las playas y el Aeropuerto.";
How can I get the NSString correctly with accents?
Many thanks
Upvotes: 1
Views: 2165
Reputation: 86651
What encoding is the data actually in? You need to use that encoding to create the string. Have a look at the raw bytes. If you see C3 BA for the accented u (\u00FA), then the data is in UTF-8. If you see 00FA, it's UTF-16 if all of the characters are two bytes or possibly ISO-LATIN-1 if not.
Having got the right encoding, how are you actually printing the string to look at it? Sometimes NSLog or the debugger, for instance, substitute non ASCII characters with escaped sequences. What you have might actually be working.
Upvotes: 1