ASP.NET获取汉字拼音的第一个字母

asp.net|汉字|拼音

<script language="vbs" src="spellcode.vbs"></script>

'获取客户简称的拼音缩写
            function getpy()
                dim str
                dim i
                str=document.all.txtContactName.value
                dim ret
                for i=1 to len(str)
                    ret=ret&getpychar(mid(str,i,1))
                next
                document.all.txtSpellCode.value=ret
        end function
    getpychar=char
    end if
end function
spellCode.vbs

'获取汉字拼音第一字母
function getpychar(char)
    dim tmp
    tmp=65536+asc(char)
    if(tmp>=45217 and tmp<=45252) then 
    getpychar= "A"
    elseif(tmp>=45253 and tmp<=45760) then
    getpychar= "B"
    elseif(tmp>=45761 and tmp<=46317) then
    getpychar= "C"
    elseif(tmp>=46318 and tmp<=46825) then
    getpychar= "D"
    elseif(tmp>=46826 and tmp<=47009) then 
    getpychar= "E"
    elseif(tmp>=47010 and tmp<=47296) then 
    getpychar= "F"
    elseif(tmp>=47297 and tmp<=47613) then 
    getpychar= "G"
    elseif(tmp>=47614 and tmp<=48118) then
    getpychar= "H"
    elseif(tmp>=48119 and tmp<=49061) then
    getpychar= "J"
    elseif(tmp>=49062 and tmp<=49323) then 
    getpychar= "K"
    elseif(tmp>=49324 and tmp<=49895) then 
    getpychar= "L"
    elseif(tmp>=49896 and tmp<=50370) then 
    getpychar= "M"
    elseif(tmp>=50371 and tmp<=50613) then 
    getpychar= "N"
    elseif(tmp>=50614 and tmp<=50621) then 
    getpychar= "O"
    elseif(tmp>=50622 and tmp<=50905) then
    getpychar= "P"
    elseif(tmp>=50906 and tmp<=51386) then 
    getpychar= "Q"
    elseif(tmp>=51387 and tmp<=51445) then 
    getpychar= "R"
    elseif(tmp>=51446 and tmp<=52217) then 
    getpychar= "S"
    elseif(tmp>=52218 and tmp<=52697) then 
    getpychar= "T"
    elseif(tmp>=52698 and tmp<=52979) then 
    getpychar= "W"
    elseif(tmp>=52980 and tmp<=53688) then 
    getpychar= "X"
    elseif(tmp>=53689 and tmp<=54480) then 
    getpychar= "Y"
    elseif(tmp>=54481 and tmp<=62289) then
    getpychar= "Z"
    else '如果不是中文,则不处理
    getpychar=char
    end if
end function

时间: 2024-08-30 04:35:45

ASP.NET获取汉字拼音的第一个字母的相关文章

ASP中获取汉字拼音的第一个字母

汉字|拼音 <script language="vbs" src="spellcode.vbs"> </script> '获取客户简称的拼音缩写 function getpy() dim str dim i str=document.all.txtContactName.value dim ret for i=1 to len(str) ret=ret&getpychar(mid(str,i,1)) next document.all

MySQL数据库获取汉字拼音的首字母函数

原文:MySQL数据库获取汉字拼音的首字母函数 需求简介:最近的一个项目,想实现如下图所示的显示效果.很明显,如果能够获取对应的汉字词组的拼音首字母就可以实现了,如果是固定的几个汉字,人为的拼一下就可以了,不过项目中有多处功能是需要这个效果的,并且事先也不知道对应的汉字是什么,所以就需要一个函数来完成这件事情了,根据网上查询的资料自己改进了一个函数实现的效果,现分享如下. 1:测试环境      1-1:测试工具的信息           1-2:测试数据库的信息      2:测试数据    

wp手机开发之获取汉字拼音的首字母

今天介绍一种新的方法,使用codeplex上开源的项目GB2312 for Silverlight. 1.创建一个项目,命名为mangoGB2312 2.将GB2312 for Silverlight项目中的两个文件都拷贝至项目目录GB2312下,并且修改GB2312Encoding.cs的命名空间为mangoGB2312.GB2312,如下图所示 开发之获取汉字拼音的首字母 -js获取汉字拼音首字母"> 3.将gb2312.bin的生成方式修改为嵌入式资源,如下图 4.编写提取汉字首字母

php获取汉字拼音首字母的函数(真正可以使用的

现实中我们经常看到这样的说明,排名不分先后,按姓名首字母进行排序.这是中国人大多数使用的排序方法.那么在php程序中该如何操作呢?下面就分享一下在php程序中获取汉字拼音的首字母的方法,在网上搜到的大多数是有问题的,这个可是经过作者实践应用过的,真的可以使用的哦. //php获取中文字符拼音首字母 function getFirstCharter($str){ if(empty($str)){return '';} $fchar=ord($str{0}); if($fchar>=ord('A')

php获取汉字拼音首字母的方法_php技巧

现实中我们经常看到这样的说明,排名不分先后,按姓名首字母进行排序.这是中国人大多数使用的排序方法.那么在php程序中该如何操作呢? 下面就分享一下在php程序中获取汉字拼音的首字母的方法,在网上搜到的大多数是有问题的,这个可是经过小编实践应用过的,真的可以使用的哦. //php获取中文字符拼音首字母 function getFirstCharter($str){ if(empty($str)){return '';} $fchar=ord($str{0}); if($fchar>=ord('A'

java字符串获取汉字拼音首字母的实现方法

问题描述 java字符串获取汉字拼音首字母的实现方法 网上有很多方法可以通过汉字来获取汉字拼音的首字母,我要实现的是这个字符串当中 还包含了特殊符号,比如字符串为:省辖市属(地区.州.直辖市区),想要获得最终 结果为:SXSS(DQZZXSQ),请各位大侠支招 解决方案 按描述你对获取汉字首字母应该没问题, 对含特殊符号的字符串,可先提取其中的汉字,然后再获取拼音啊 public static String getChineseCode(String retCode){ Pattern patt

ASP.NET 根据汉字获取汉字拼音的首字母(含多音字)_实用技巧

在很多时候,我们需要将汉字的拼音首字母存储到数据库,以便我们能通过首字母进行快速的查询,常见的有百度搜索,你只要输入拼音的首字母,就会出现相关的搜索的关键词,再比如一些办公系统中,查询一个人的姓名,为了简单方便,只输这个人的名字的首字母,就能快速检索. 话不多说,代码分享给大家: #region 获取汉字转换拼音 首字母 public string MkPinyinString(string HanZiStr) //获取汉字字符串的拼音首字母,含多音字 { int i, j, k, m; str

Java获取汉字拼音的全拼和首拼实现代码分享_java

import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; /** * 将汉字转化为全拼 */ public class CnToSpell1 { private static Map<String, Integer> spellMap = null; //存放生僻字和其拼音的Map private static Map<Cha

asp.net 获得汉字拼音的首字母

asp教程.net 获得汉字拼音的首字母 提供一个经典的获得汉字拼音的首字母函数,希望对各位的有用. public string GetPYChar(string c)         {             byte[] array = new byte[2];             array = System.Text.Encoding.Default.GetBytes(c);             int i = (short)(array[0] - '') * 256 + ((