![](http://static.blog.csdn.net/images/category_icon.jpg)
版权声明:本文为博主原创文章,未经博主允许不得转载。
调用CFStringTransform方法进行汉字转拼音和拼音转英文:
- 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);
- }
- }