//将NSString装换成NSMutableString
NSMutableString *pinyin = [chinese mutableCopy];
//将汉字转换为拼音(带音标)
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
NSLog(@"带音标%@", pinyin);
//去掉拼音的音标
CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripCombiningMarks, NO);
NSLog(@"不带音标%@", pinyin);
//全部大写
pingyin = [pingyin uppercaseString];
//全部小写
pingyin = [pingyin lowercaseString];
//返回第一个字母
[pingyin substringToIndex:1];
网友评论