获取拼音首字母(传入汉字字符串, 返回大写拼音首字母)
来源:互联网 发布:c语言上机心得体会 编辑:程序博客网 时间:2024/04/30 07:37
//获取拼音首字母(传入汉字字符串, 返回大写拼音首字母)
- (NSString *)firstCharactor:(NSString *)aString
{
//转成了可变字符串
NSMutableString *str = [NSMutableString stringWithString:aString];
//先转换为带声调的拼音
CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformMandarinLatin,NO);
//再转换为不带声调的拼音
CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformStripDiacritics,NO);
//转化为大写拼音
NSString *pinYin = [str capitalizedString];
//获取并返回首字母
return [pinYin substringToIndex:1];
}
- (NSString *)firstCharactor:(NSString *)aString
{
//转成了可变字符串
NSMutableString *str = [NSMutableString stringWithString:aString];
//先转换为带声调的拼音
CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformMandarinLatin,NO);
//再转换为不带声调的拼音
CFStringTransform((CFMutableStringRef)str,NULL, kCFStringTransformStripDiacritics,NO);
//转化为大写拼音
NSString *pinYin = [str capitalizedString];
//获取并返回首字母
return [pinYin substringToIndex:1];
}
0 0
- 获取拼音首字母(传入汉字字符串, 返回大写拼音首字母)
- PHP 获取汉字拼音首字母大写
- 获取汉字拼音首字母
- 获取汉字拼音首字母
- 获取汉字拼音首字母
- 获取汉字拼音首字母
- 获取汉字拼音首字母
- 获取汉字拼音首字母
- 获取汉字拼音首字母
- 取汉字拼音大写首字母
- vb 获取字符串汉字拼音的首字母
- 获取字符串中的汉字拼音首字母
- 获取字符串首字母拼音
- 获得汉字字符串拼音首字母
- 获得汉字字符串拼音首字母
- 获得汉字字符串拼音首字母
- 获得汉字字符串拼音首字母 .
- 获得汉字字符串拼音首字母
- dp, sp, 与 px 互相转换的工具类
- 硬币问题 算法第五集
- java Properties文件key-value值的读与写
- 20151126(mysql,eclipse for javaee)
- 数字大作战:宽带报障系列之错误633
- 获取拼音首字母(传入汉字字符串, 返回大写拼音首字母)
- spring scope注解说明 singleton prototype request session global session
- 凸凹函数的定义
- es store详解
- UITabBar(拓展)
- error LNK2026: 模块对于 SAFESEH 映像是不安全的
- c++11conditon_variable的wait在类中的等待条件
- 2015-11-26 晒桌面
- Debug和release