您的位置:首页 > 移动开发 > IOS开发

iOS 汉字转拼音

2016-09-26 17:18 253 查看
- (NSString *)getFirstString:(ICCustom *)custom {
NSMutableString *source = [custom.merchantAbbreviation mutableCopy];
if(source && custom.merchantAbbreviation.length>0)

{
CFRange range = CFRangeMake(0, 1);
CFStringTransform((__bridge CFMutableStringRef)source, &range, kCFStringTransformMandarinLatin, NO);
CFStringTransform((__bridge CFMutableStringRef)source, &range, kCFStringTransformStripDiacritics, NO);
NSString *phonetic = source;
phonetic = [phonetic substringToIndex:1];
phonetic = [phonetic uppercaseString];
int temp = [phonetic characterAtIndex:0];
if (temp < 65 || temp > 122 || (temp > 90 && temp < 97)) {
//不合法的title
phonetic = @"#";
}else{
phonetic = phonetic;
}
return phonetic;
}else
{
return @"#";
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: