0

I'm receiving a json data from server with some strings inside. I use SBJson https://github.com/stig/json-framework to get them.

However when I output some strings at UILabel they look like this: \u0418\u043b\u044c\u044f\u0411\u043b\u043e\u0445 (that's Cyrillic symbols)

And it's all right with latin characters

How can I decode it into normal symbols?

Some code about getting data:

   NSData * data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];   
   NSString *stringData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
   NSDictionary *object = [parser objectWithString:stringData error:nil];
   NSString *comments = [NSString stringWithFormat:@"%@",[object valueForKey:@"comments"]];

String comments has a very special format, so I'm doing some operation like stringByTrimmingCharactersInSet ,

stringByReplacingOccurrencesOfString ,

NSArray* json_fields = [comments_modified componentsSeparatedByString: @";"];

to get a final data.

This is an example of received data after some trimming/replacing (it's NSString* comments):

"already_wow"=0;"date_created"="2012/03/1411:11:18";id=41598;name="\U0418\U043b\U044c\U044f\U0411\U043b\U043e\U0445";text="\U0438\U043d\U0442\U0435\U0440\U0435\U0441\U043d\U043e";"user_id"=1107;"user_image"="user_image/a6/6f/96/21/20111220234109510840_1107.jpg";"user_is_deleted"=0;username=IlyaBlokh;"wow_count"=0;

You see that fields text and name are encoded

If I display them on the view (at UILabel for example), they still look the same

Owen Blacker
  • 4,117
  • 2
  • 33
  • 70
Ilya Blokh
  • 11,923
  • 11
  • 52
  • 84
  • @Erik Aigner, yes, my code is the same. Look my updated question - you see, I use `NSUTF8StringEncoding` configuring a string before parse it – Ilya Blokh Mar 15 '12 at 07:59

1 Answers1

0

maybe the string returned is just the unicode string representation (ascii string), that's means not returned the content encoded with utf8, to try this with NSASCIIStringEncoding to get stringData

Wubao Li
  • 1,728
  • 10
  • 13