直接附上代码:
- (NSString *)transformToPinyinWithStr:(NSString *)str{
NSMutableString *mutableString = [NSMutableString stringWithString:str];
CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, false);
mutableString = (NSMutableString *)[mutableString stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:[NSLocale currentLocale]];
return mutableString;
}
网友评论