Created
May 21, 2013 04:31
-
-
Save lexrus/5617493 to your computer and use it in GitHub Desktop.
Initial Phonetic Letter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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