我需要将以下内容转换为字符串并显示
Overall, the \u2018\u2018typical\u2019\u2019 xyz is broadly expressed
我尝试过各种非编码转换
NSData *asciiData = [desc dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *encodedString = [[NSString alloc] initWithData:asciiData encoding:NSASCIIStringEncoding
和
[NSString stringByReplacingOccurrencesOfString:@"\u2018" withString:@""]
没有成功。
请建议我解决这个问题。
答案 0 :(得分:1)
char cString[] = "\u2018\u2018typical\u2019\u2019";
NSString *string = [NSString stringWithCString:cString encoding:NSUTF8StringEncoding];
NSLog(@"string: %@", string);
NSLog输出:string:''typical''
或
NSData *data = [NSData dataWithBytes:cString length:strlen(cString)];
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"string: %@", string);
NSLog输出:string:''typical''