开发者

iPhone: Convert Unicode to string

I need to convert the following to string and display

Overall, the \u2018\u2018typical\u2019\u2019 xyz is broadly expressed
开发者_开发百科

I have tried all sort of uncode conversion

NSData *asciiData = [desc dataUsingEncoding:NSASCIIStringEncoding   allowLossyConversion:YES]; 
NSString *encodedString = [[NSString alloc] initWithData:asciiData encoding:NSASCIIStringEncoding

and:

[NSString stringByReplacingOccurrencesOfString:@"\u2018" withString:@""]

without success.

Kindly suggest me a solution to this.


char cString[] = "\u2018\u2018typical\u2019\u2019";
NSString *string = [NSString stringWithCString:cString encoding:NSUTF8StringEncoding];
NSLog(@"string: %@", string);

NSLog output: string: ‘‘typical’’

or

NSData *data = [NSData dataWithBytes:cString length:strlen(cString)];
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"string: %@", string);

NSLog output: string: ‘‘typical’’

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜