iOS 汉字转拼音
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 @"#";
}
}
!--?xml>以上是关于iOS 汉字转拼音的主要内容,如果未能解决你的问题,请参考以下文章