转载http://blog.fwhyy.com/2012/03/take-the-first-initials-method-of-csharp-and-vbnet/…
/// <summary> /// 获得一个字符串的汉语拼音码 /// </summary> /// <param name="strText">字符串</param> /// <returns>汉语拼音码,该字符串只包含大写的英文字母</returns> public static string GetChineseSpell(string strText) { if (strText == null || st…
'/ <summary> '/ 获得一个字符串的汉语拼音码 '/ </summary> '/ <param name="strText">字符串</param> '/ <returns>汉语拼音码,该字符串只包含大写的英文字母</returns> Public Shared Function GetChineseSpell(ByVal strText As String) As String If strText…
//取字符串拼音首字母 function makePy(str) { if (typeof(str) != "string") throw new Error(-1, "函数makePy需要字符串类型参数!"); var arrResult = new Array(); //保存中间结果的数组 for (var i = 0, len = str.length; i < len; i++) { //获得unicode码 var ch = str.charAt(i…
sqlserver 使用函数获取一个字符串的拼音首字母 create function dbo.fn_getpinyin ( @str nvarchar(max) ) returns nvarchar(max) as begin ),@PY nvarchar(max) set @PY='' begin ) --如果非汉字字符,返回原字符 PY from ( select 'A' as PY,N'驁' as word union all select 'B',N'簿' union all sele…
)='') ) as begin ), ) , ,) if @chn > 'z' if( @chn < '八' ) set @c = 'A' else if ( @chn < '嚓' ) set @c = 'B' else if ( @chn < '咑' ) set @c = 'C' else if ( @chn < '妸' ) set @c = 'D' else if ( @chn < '发' ) set @c = 'E' else if ( @chn < '旮…
1.获得一个字符串的每个字的拼音首字母构成所需的字符串 #region  获取首字母 /// <summary>         /// 这个办法是用来获得一个字符串的每个字的拼音首字母构成所需的字符串         /// </summary>         /// <param name="str"></param>         /// <returns></returns>         publi…
if exists (select * from sysobjects where id = object_id(N'[fn_ChineseToSpell]') and xtype in (N'FN', N'IF', N'TF')) www.2cto.com drop function [fn_ChineseToSpell]GO/*创建取拼音首字母函数*/ create function [dbo].[fn_ChineseToSpell](@strChinese varchar(500)='')…
问:对于拼音和拼音首字母的支持,当你在搜商品的时候,如果想输入拼音和拼音首字母就给出商品的信息,怎么办呢? 实现方式有2种,但是他们其实是对应的.  用lucene实现 1.建索引, 多建一个索引字段,即拼音和拼音首字母这2个字段.合并的一个字段.  (拼音和拼音首字母,可以通过pinyin4j.jar.将想要进行拼音搜索的字段进行拼音转换.) 2.对输入的参数判断是否是拼音,(可以通过将传人的值转换为 utf-8 形式,如果转换后的字符串长度大于原来的字符串的长度,那么就不是拼音.否则就进行拼…
function getfirst($str, $charset='utf8'){         $dict=array(         'a'=>0xB0C4,         'b'=>0xB2C0,         'c'=>0xB4ED,         'd'=>0xB6E9,         'e'=>0xB7A1,         'f'=>0xB8C0,         'g'=>0xB9FD,         'h'=>0xBBF6, …