ios汉字转拼音

直接附上代码:

- (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;
}

你可能感兴趣的:(ios汉字转拼音)