iOS将汉字转换为拼音】的更多相关文章

将汉字转换为拼音 - (NSString *)chineseToPinyin:(NSString *)chinese withSpace:(BOOL)withSpace { CFStringRef hanzi = (__bridge CFStringRef)chinese; CFMutableStringRef string = CFStringCreateMutableCopy(NULL, 0, hanzi); CFStringTransform(string, NULL, kCFString…
在iOS开发中经常涉及到汉字的排序,最常见的就是需要根据首字母的字符顺序排列,比如常见的通讯录等.总结出来,大致可以分为两种方法,其中参考文献[1]中提供的方法十分复杂,利用查表的方法是先,并且代码量很大,不建议采用.另一种方法是直接采用Core Foundation中提供的方法,十分简单,封装好的代码如下: - (NSString *)transform:(NSString *)chinese{ //将NSString装换成NSMutableString NSMutableString *pi…
在项目中经常会遇到需求用户输入汉字后转换为拼音的场景,比如说通讯录,就会要求按名字首字符发音排序,如果自己写实现这方面的功能是个很好大的工程,还好网上有公开的第三方jar支持转换,结合网上很多前辈的代码,copy了两个简单的工具方法,供参考 第一个是使用pinyin4j的jar,此jar对多音字语句的处理不太理想 package com.lovo.utils; import org.springframework.stereotype.Component; import net.sourcefo…
之前做通讯录相关的一些App时,有一个比较常用的算法是将汉字转换成拼音.当时采用的做法是:将各个拼音段的首个汉字(按Unicode排序)做成两个数组,一个数组存拼音,另一个数组存拼音对应首个汉字的Unicode.如果要获取某个汉字的拼音,可以折半查找法找的对应拼音.最近无意间发现CFStringTransform这篇文章后,发现系统本身已经提供了一个这样的函数. CFStringTransform iOS在CoreFoundation中提供了CFStringTransform函数,但在Found…
iOS/Mac OS X 汉字转拼音 网络流行的汉字转拼音方案是带一个拼音码表,速度快.其实Core Foundation也提供了一种方案,而且还带声调! NSMutableString *ms = [[NSMutableString alloc] initWithString:@"我是中国人"]; if (CFStringTransform((__bridge CFMutableStringRef)ms, 0, kCFStringTransformMandarinLatin, NO)…
package com.Test.util; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; import net.sourceforge.pinyin4j.format.HanyuPinyinToneTyp…
sql数据库自定义一个函数把下面代码写进去 功能是得到汉字拼音首字母create function fun_getPY(@str nvarchar(4000)) returns nvarchar(4000) as begin declare @word nchar(1),@PY nvarchar(4000) set @PY='' while len(@str)>0 begin set @word=left(@str,1) --如果非汉字字符,返回原字符 set @PY=@PY+(case whe…
将JSPinyin剥离mootools这个JavaScript库,可以独立使用. 1)一个是将汉字翻译为拼音,其中每一个字的首字母大写: pinyin.getFullChars(this.value); 2)一个是可以将每一个字的拼音的首字母提取出来,是大写的形式. pinyin.getCamelChars(this.value); 源码: /* --- description: Pinyin, to get chinese pinyin from chinese. license: MIT-s…
片段 1 片段 2 gistfile1.txt /* --- description: Pinyin, to get chinese pinyin from chinese. license: MIT-style authors: Bill Lue requires: core/1.2.1: '*' provides: [Pinyin] ... */ //(function( window, undefined ){ // var Pinyin = new Class({ var pinyin…
using System; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; public partial…