汉字转拼音,iOS自带库,中文排序的一定要看

1
2
3
4
5
6
7
NSMutableString *ms = [[NSMutableString alloc] initWithString:@"我是中国人"];
if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformMandarinLatin, NO)) {
    NSLog(@"Pingying: %@", ms); // wǒ shì zhōng guó rén
}
if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformStripDiacritics, NO)) {
    NSLog(@"Pingying: %@", ms); // wo shi zhong guo ren
}

Leave a Reply