汉字转拼音

1
2
3
4
5
6
7
8
9
10
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); 
    
}
posted @ 2019-06-16 17:58  袁氏家谱网  阅读(187)  评论(0编辑  收藏  举报