0

This is my code

for(id tempLangItem in jp.staffData)
        {
 NSMutableDictionary *temp=[[NSMutableDictionary alloc] initWithDictionary:tempLangItem];
            NSString *name = [temp objectForKey:@"lang_name"];
            NSLog(@"item_name =%@",name);
            NSLog(@"value in dictionary=%@",temp);



}  

These are log details

item_name =marinieres

 value_in_dictionary={
    "lang_id" = 2;
    "lang_name" = "\U7a46\U840a\U65afmarinieres";
    time = "2013-06-05 05:14:50";
}

why it is giving lang_name=\U7a46\U840a\U65afmarinieres in value_in_dictionary logs while it is displaying correct in item_name log.

Suraj Gupta
  • 200
  • 9
  • What are the `tempLangItem`-dictionary your `temp`-dictionary are initialized with? Could you include it in you code, perhaps? – mfaerevaag Jun 06 '13 at 07:04
  • @7SLEVIN Now check my code i have made some improvements. – Suraj Gupta Jun 06 '13 at 07:07
  • @7SLEVIN jp.staff data is an NSArray of NSdictionary. – Suraj Gupta Jun 06 '13 at 07:08
  • Convert the string into the proper format as these are the UTF characters that are being displayed – Akhilesh Sharma Jun 06 '13 at 07:09
  • Please find the below question: http://stackoverflow.com/questions/14980421/arabic-characters-in-json-decoding – manujmv Jun 06 '13 at 07:23
  • Is that string supposed to contain 穆萊斯 at the beginning? Note that \U expects eight hex digits and \u is used for four hex digits, which may be the reason why they’re being ignored when showing the string with `NSLog()`. Could you edit your question and show the corresponding JSON string? It could be a problem in your JSON provider or the JSON parser you’re using. –  Jun 06 '13 at 08:04

1 Answers1

2

Tried

NSMutableDictionary *temp=[[NSMutableDictionary alloc]init];
[temp setObject:@"marinieres" forKey:@"lang_name"];

NSString *name = [temp objectForKey:@"lang_name"];
NSLog(@"item_name =%@",name);
NSLog(@"value in dictionary=%@",temp);

and what my log shows

2013-06-06 12:38:02.337 Cool[96423:11303] item_name =marinieres
2013-06-06 12:38:04.022 Cool[96423:11303] value in dictionary={
    "lang_name" = marinieres;
}

1 Quick question: if it is an NSDictionary why you creating a new instance?

 NSMutableDictionary *temp=[[NSMutableDictionary alloc] initWithDictionary:tempLangItem];

try with tempLangItem

Lithu T.V
  • 19,955
  • 12
  • 56
  • 101