一种将汉字转换为拼音的更简单的方法

 

//直接上代码吧

        NSMutableString *string = [@"苹果" mutableCopy];

        NSLog(@"Before: %@", string); // Before: 苹果

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

        NSLog(@"After: %@", string);  // After: píng guǒ

        CFStringTransform((__bridge CFMutableStringRef)string, NULL, kCFStringTransformStripDiacritics, NO);

        NSLog(@"Striped: %@", string); // Striped: ping guo

posted on 2014-10-29 17:34  恒山之阳  阅读(146)  评论(0编辑  收藏  举报

导航