iOS CFStringTransForm汉字转拼音

时间:2021-10-02 13:37:14

CFStringTransform

- (NSString *) phonetic:(NSString*)sourceString {

NSMutableString *source = [sourceString mutableCopy];

CFStringTransform((__bridge CFMutableStringRef)source, NULL, kCFStringTransformMandarinLatin, NO);

CFStringTransform((__bridge CFMutableStringRef)source, NULL, kCFStringTransformStripDiacritics, NO);

return source;

}