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…
在项目中经常会遇到需求用户输入汉字后转换为拼音的场景,比如说通讯录,就会要求按名字首字符发音排序,如果自己写实现这方面的功能是个很好大的工程,还好网上有公开的第三方jar支持转换,结合网上很多前辈的代码,copy了两个简单的工具方法,供参考 第一个是使用pinyin4j的jar,此jar对多音字语句的处理不太理想 package com.lovo.utils; import org.springframework.stereotype.Component; import net.sourcefo…
///<summary> /// 汉字转拼音缩写 /// Code By         ] -'\0')); if ( i <0xB0A1) return"*"; if ( i <0xB0C5) return"a"; if ( i <0xB2C1) return"b"; if ( i <0xB4EE) return"c"; if ( i <0xB6EA) return"d&…
/// 〈summary〉 /// 汉字转拼音缩写 /// Code By MuseStudio@hotmail.com /// 2004-11-30 /// 〈/summary〉 /// 〈param name="str"〉要转换的汉字字符串〈/param〉 /// 〈returns〉拼音缩写〈/returns〉 public string GetPYString(string str) { string tempStr = ""; foreach(char c…
将汉字转换为拼音 - (NSString *)chineseToPinyin:(NSString *)chinese withSpace:(BOOL)withSpace { CFStringRef hanzi = (__bridge CFStringRef)chinese; CFMutableStringRef string = CFStringCreateMutableCopy(NULL, 0, hanzi); CFStringTransform(string, NULL, kCFString…
之前做通讯录相关的一些App时,有一个比较常用的算法是将汉字转换成拼音.当时采用的做法是:将各个拼音段的首个汉字(按Unicode排序)做成两个数组,一个数组存拼音,另一个数组存拼音对应首个汉字的Unicode.如果要获取某个汉字的拼音,可以折半查找法找的对应拼音.最近无意间发现CFStringTransform这篇文章后,发现系统本身已经提供了一个这样的函数. CFStringTransform iOS在CoreFoundation中提供了CFStringTransform函数,但在Found…
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…
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…
将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…