Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用[str UTF8String]或[str cStringUsingEncoding:NSUTF8StringEncoding]
[str UTF8String]
[str cStringUsingEncoding:NSUTF8StringEncoding]
NSString:
Nikita's iPad
给出输出:
Nikita\xe2\x80\x99s iPad
我该如何保留它'?
'
您使用了错误的撇号。
这个:
[@"Nikita's iPad" UTF8String];
提供正确的输出
[@"Nikita’s iPad" UTF8String];
给出了这个:
您可以像这样替换字符:
NSString *new = [old stringByReplacingOccurrencesOfString:@"’" withString:@"'"];