汉字转拼音 系统库实现:
NSString *city = @"杭州";
// 或者使用:NSMutableString *cityP = [city mutableCopy];
NSMutableString *cityP = [[NSMutableString alloc] initWithString:city];
//转换成拼音
CFStringTransform((__bridge CFMutableStringRef)cityP, NULL, kCFStringTransformMandarinLatin, NO);
//去声调
CFStringTransform((__bridge CFMutableStringRef)cityP, NULL, kCFStringTransformStripDiacritics, NO);```
就是这么简单~
网友评论