标签:
将汉字转换为拼音
- (NSString *)chineseToPinyin:(NSString *)chinese withSpace:(BOOL)withSpace {
CFStringRef hanzi = (__bridge CFStringRef)chinese;
CFMutableStringRef string = CFStringCreateMutableCopy(NULL, 0, hanzi);
CFStringTransform(string, NULL, kCFStringTransformMandarinLatin, NO);
CFStringTransform(string, NULL, kCFStringTransformStripDiacritics, NO);
NSString *pinyin = (NSString *)CFBridgingRelease(string);
if (!withSpace) {
pinyin = [pinyin stringByReplacingOccurrencesOfString:@" " withString:@""];
}
return pinyin;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/realank/article/details/47401815