0

i have a question that i get a NSString(maybe i called it astring) form a stream server when i print this astring ,shows\u5f20\u9510\u7b49\u540c\u5fd7\u4efb in console.

It's a NSString(astring) that can be printed to\u5f20\u9510\u7b49\u540c\u5fd7\u4efb by console , and is not such like a NSString* bstring=@"\u5f20\u9510\u7b49\u540c\u5fd7\u4efb"

now, i want to convert this astring to a nsstring which may contains simple chinese character. how could i do this? Thanks very much! for more detail, the astring is\\u5f20\\u9510\\u7b49\\u540c\\u5fd7\\u4efb in memory

ben
  • 1,020
  • 1
  • 15
  • 27
  • 1
    There’s no need to convert anything. `@"\u5f20\u9510\u7b49\u540c\u5fd7\u4efb"` is the same as `@"张锐等同志任"`. Maybe you could edit your question and paste the code you’re using, which would help us understand why you would need conversion. –  Jun 12 '11 at 05:14
  • So the string you’re receiving from the server is actually `@"\\u5f20\\u9510\\u7b49\\u540c\\u5fd7\\u4efb"`? –  Jun 12 '11 at 05:19
  • how are you getting the content? – Deepak Danduprolu Jun 12 '11 at 05:43
  • @Bavarious i used asihttp,get a respond nsdata,then convert to nsstring,that is what i get now – ben Jun 12 '11 at 05:49

1 Answers1

1
NSString *aString = [NSString stringWithUTF8String:"\u5f20\u9510\u7b49\u540c\u5fd7\u4efb"];
NSLog(@"%@", aString);

This should work right?

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
  • oh,thanks ,but it's not what i want to.i have edit my question,let you know clear. – ben Jun 12 '11 at 05:17