Skip to content

Instantly share code, notes, and snippets.

@revolc
Created June 6, 2015 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revolc/c22c6c5a62f297ffb063 to your computer and use it in GitHub Desktop.
Save revolc/c22c6c5a62f297ffb063 to your computer and use it in GitHub Desktop.
NSMutableString *pinyin = [name mutableCopy];
if (!CFStringTransform((__bridge CFMutableStringRef)pinyin, 0, kCFStringTransformMandarinLatin, NO)) {
DDLogWarn(@"拼音转换[步骤1]失败: %@ -> %@", name, pinyin);
}
if (!CFStringTransform((__bridge CFMutableStringRef)pinyin, 0, kCFStringTransformStripDiacritics, NO)) {
DDLogWarn(@"拼音转换[步骤2]失败: %@ -> %@", name, pinyin);
}
pinyin = [pinyin stringByReplacingOccurrencesOfString:@" " withString:@""];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment