Skip to content

Instantly share code, notes, and snippets.

@lexrus
Created May 21, 2013 04:31
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 lexrus/5617493 to your computer and use it in GitHub Desktop.
Save lexrus/5617493 to your computer and use it in GitHub Desktop.
Initial Phonetic Letter
static NSString *phonetic(NSString *sourceString) {
NSMutableString *source = [sourceString mutableCopy];
CFStringTransform((__bridge CFMutableStringRef) source, NULL, kCFStringTransformMandarinLatin, NO);
return source;
}
static inline NSString *initialPhoneticLetter(NSString *string) {
return [[[[phonetic([string substringToIndex:1]) substringToIndex:1] uppercaseString]
stringByReplacingOccurrencesOfString:@"\u0100" withString:@"A"]
stringByReplacingOccurrencesOfString:@"\u00c9" withString:@"E"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment