iOS-汉字转拼音

- (NSString *)transform:(NSString *)chinese

{

    NSMutableString *pinyin = [chinese mutableCopy];

    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);

    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripCombiningMarks, NO);

    NSLog(@"%@", pinyin);

    return [[pinyin uppercaseString] substringToIndex:1];

}

你可能感兴趣的:(代码笔记)