以下是ios Unicode编码转成中文的方法,无gbk和utf-8区别,代码如下,方法复制过去即可用。
//输入unicode字符自动转中文 - (NSString*) replaceUnicode:(NSString*)TransformUnicodeString{ NSString *tepStr1 = [TransformUnicodeString stringByReplacingOccurrencesOfString:@"\\u"withString:@"\\U"]; NSString *tepStr2 = [tepStr1 stringByReplacingOccurrencesOfString:@"\""withString:@"\\\""]; NSString *tepStr3 = [[@"\"" stringByAppendingString:tepStr2]stringByAppendingString:@"\""]; NSData *tepData = [tepStr3 dataUsingEncoding:NSUTF8StringEncoding]; NSString *wordStr = [NSPropertyListSerialization propertyListWithData:tepData options:NSPropertyListMutableContainers format:nil error:nil]; return [wordStr stringByReplacingOccurrencesOfString:@"\\r\\n"withString:@"\n"]; }