首页 > 代码库 > iOS 汉字转拼音
iOS 汉字转拼音
- (NSString *)getFirstString:(ICCustom *)custom {
NSMutableString *source = [custom.merchantAbbreviation mutableCopy];
if(source && custom.merchantAbbreviation.length>0)
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 @"#";
}
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 @"#";
}
}
iOS 汉字转拼音
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。