Objective-C Unicode 转换成中文

Objective-C Unicode 转换成中文


转自
http://lupingui.iteye.com/blog/857213


  1. + (NSString *)replaceUnicode:(NSString *)unicodeStr {  
  2.       
  3.     NSString *tempStr1 = [unicodeStr stringByReplacingOccurrencesOfString:@"\\u" withString:@"\\U"];  
  4.     NSString *tempStr2 = [tempStr1 stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];  
  5.     NSString *tempStr3 = [[@"\"" stringByAppendingString:tempStr2] stringByAppendingString:@"\""];  
  6.     NSData *tempData = [tempStr3 dataUsingEncoding:NSUTF8StringEncoding];  
  7.     NSString* returnStr = [NSPropertyListSerialization propertyListFromData:tempData  
  8.                                                                                              mutabilityOption:NSPropertyListImmutable   
  9.                                                                                                             format:NULL  
  10.                                                                                               errorDescription:NULL];  
  11.       
  12.     //NSLog(@"Output = %@", returnStr);  
  13.       
  14.     return [returnStr stringByReplacingOccurrencesOfString:@"\\r\\n" withString:@"\n"];  
  15. }  

你可能感兴趣的:(Objective-C Unicode 转换成中文)