iPhone, special characters in JSON Response

Posted by eddit on Stack Overflow See other posts from Stack Overflow or by eddit
Published on 2009-09-24T03:12:53Z Indexed on 2010/05/05 5:48 UTC
Read the original article Hit count: 210

Filed under:
|
|
|
|

Writing an iphone app, and I'm getting my data from a REST API that returns JSON. My problem is, some of the data has special characters embedded and Im getting errors. Example:

MartÌn
Petite-RiviËre-Saint-FranÁois

Here is my current code:

NSString *jsonString = [[NSString alloc] 
                            initWithData:receivedData 
                            encoding:NSUTF8StringEncoding];
NSMutableArray *tempResults = [[[jsonString JSONValue] 
                            objectForKey:@"getRegionResortsLastUpdatedResponse"] 
                            objectForKey:@"return"];

Whenever the data has special characters in it "jsonString" return "(null)", otherwise everything works fine.

Is this something I can handle on my end, or does the API need to be modified to output the character codes?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about api