苹果自带拼音转换方法
1 - (NSString *)getPinYinFrom:(NSString *)chinese
2 { 3 CFMutableStringRef string = CFStringCreateMutableCopy(NULL, 0, (__bridge CFMutableStringRef)[NSMutableString stringWithString:chinese]); 4 CFStringTransform(string, NULL, kCFStringTransformMandarinLatin, NO); 5 CFStringTransform(string, NULL, kCFStringTransformStripDiacritics, NO); 6 7 NSMutableString *aNSString = (__bridge NSMutableString *)string; 8 NSString *finalString = [aNSString stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%c", 32] withString:@""]; 9 10 NSLog(@"%@", finalString);11 return finalString;
时间: 2024-10-21 19:40:00