I have some data that contains UTF8 characters. If I do following I can able to see characters correctly in console:
NSString *responseData = [[NSString alloc]
initWithData:urlData
encoding:NSUTF8StringEncoding];
NSLog(@"Response = %@", responseData);
Output
{"success":1,"row":1,"no":"001","title":"Arendi iOS","subject":"Konu 1","describtion":"Aciklama 1 ıİöÖçÇüÜğĞ","attachment":"Eklenti 1","status":1}
After this step I am doing this:
SBJsonParser *jsonParser = [SBJsonParser new];
NSDictionary *jsonData = (NSDictionary*)[jsonParser objectWithString:responseData error:nil];
NSLog(@"jsonData = %@",jsonData);
Output:
jsonData = {
attachment = "Eklenti 2";
describtion = "Aciklama 2 \U0131\U0130\U00f6\U00d6\U00e7\U00c7\U00fc\U00dc\U011f\U011e";
no = 002;
row = 2;
status = 1;
subject = "Konu 2";
success = 1;
title = "Arendi Android";
}
After that I am doing this:
NSString *description = (NSString*)[jsonData objectForKey:@"description"];
But it gives me null
. How can I print this characters correctly?
Not sure whether it is a simple typo but I couldn't help noticing that you had a field named "description" here.
jsonData = { attachment = "Eklenti 2"; describtion = "Aciklama 2 \U0131\U0130\U00f6\U00d6\U00e7\U00c7\U00fc\U00dc\U011f\U011e"; no = 002; row = 2; status = 1; subject = "Konu 2"; success = 1; title = "Arendi Android"; }
However in the final output, you were trying to get the value of a property named "description". If key is defined as "describtion", you can't find it by "description" and parser will return "null" as expected.
Hope it helps.