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 @"#";
}
}
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 @"#";
}
}
相关文章推荐
- iOS 设置tableview头部不可以向下拉动..
- iOS 设置navigationBar背景
- iOS10的小坑
- iOS AFNetWorking 下载pdf文档
- 总结适配IOS10需要注意的问题
- 深入理解Tagged Pointer
- iOS 10 推送的简单使用
- iOS - CABasicAnimation使用总结
- IOS中safari下的select下拉菜单文字过长不换行的解决方法
- [置顶] iOS之蓝牙设备的唯一标识问题
- iOS-IPA-Release
- [iOS 转 获取字符串位置]
- ios封装生成合成.a文件
- 李洪强iOS开发之 - 指定刷新tableview的某一组
- iOS:即时通讯之<了解篇 SocKet>
- iOS开发 正则运算详细介绍
- iOS – Cocoa Touch简介:
- iOS开发之CADisplayLink
- iOS10 推送必看(基础篇)
- 关于IOS中safari下的select下拉菜单,文字过长不换行的问题