苹果自带中文转换拼音
2016-07-10 本文已影响28人
StonesMonkey
NSString *hanziText = @"我是中国人";
if ([hanziText length]) {
NSMutableString *ms = [[NSMutableString alloc] initWithString:hanziText];
if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformMandarinLatin, NO)) {
NSLog(@"pinyin: %@", ms);
}
if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformStripDiacritics, NO)) {
NSLog(@"pinyin: %@", ms);
}
}
来源:http://blog.csdn.net/dean19900504/article/details/39480329