取汉字的拼音首字母

来源:互联网 发布:algorithm算法 编辑:程序博客网 时间:2024/03/29 10:00


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
'阿楚取首字拼音
'QQ 2786103
'欢迎大家交流

function GetAsc(str)
str=Ucase(str)

'这段只是用来保留中文字间的数字,不要可删除
str=Replace(str,"0","a")
str=Replace(str,"1","b")
str=Replace(str,"2","c")
str=Replace(str,"3","d")
str=Replace(str,"4","e")
str=Replace(str,"5","f")
str=Replace(str,"6","g")
str=Replace(str,"7","h")
str=Replace(str,"8","i")
str=Replace(str,"9","j")
str=Replace(str," ","")

'开始取出
 for i=1 to len(str)
     chr_=mid(str,i,1)
 asc_=asc(chr_)
 if asc_>0 and asc_<128 then
helpchr_=helpchr_+mid(str,i,1)
else
casc_=asc_+65536
if casc_>=45217 and casc_<=45252 then
helpchr_=helpchr_+"A"
elseif casc_>=45253 and casc_<=45760 then helpchr_=helpchr_+"B"
elseif casc_>=45761 and casc_<=46317 then helpchr_=helpchr_+"C"
elseif casc_>=46318 and casc_<=46825 then helpchr_=helpchr_+"D"
elseif casc_>=46826 and casc_<=46847 then helpchr_=helpchr_+"E"
elseif casc_>=47010 and casc_<=47296 then helpchr_=helpchr_+"F"
elseif casc_>=47297 and casc_<=47613 then helpchr_=helpchr_+"G"
elseif casc_>=47614 and casc_<=48118 then helpchr_=helpchr_+"H"
elseif casc_>=48119 and casc_<=49061 then helpchr_=helpchr_+"J"
elseif casc_>=49062 and casc_<=49323 then helpchr_=helpchr_+"K"
elseif casc_>=49324 and casc_<=49895 then helpchr_=helpchr_+"L"
elseif casc_>=49896 and casc_<=50370 then helpchr_=helpchr_+"M"
elseif casc_>=50371 and casc_<=50613 then helpchr_=helpchr_+"N"
elseif casc_>=50614 and casc_<=50621 then helpchr_=helpchr_+"O"
elseif casc_>=50622 and casc_<=50905 then helpchr_=helpchr_+"P"
elseif casc_>=50906 and casc_<=51386 then helpchr_=helpchr_+"Q"
elseif casc_>=50387 and casc_<=51445 then helpchr_=helpchr_+"R"
elseif casc_>=51446 and casc_<=52217 then helpchr_=helpchr_+"S"
elseif casc_>=52218 and casc_<=52697 then helpchr_=helpchr_+"T"
elseif casc_>=52698 and casc_<=52979 then helpchr_=helpchr_+"W"
elseif casc_>=52980 and casc_<=53688 then helpchr_=helpchr_+"X"
elseif casc_>=53689 and casc_<=54480 then helpchr_=helpchr_+"Y"
elseif casc_>=54481 and casc_<=55289 then helpchr_=helpchr_+"Z"
else
helpchr_=helpchr_+" "
end if
end if
next

'这段只是用来保留中文字间的数字,不要可删除
helpchr_=Replace(helpchr_,"a","0")
helpchr_=Replace(helpchr_,"b","1")
helpchr_=Replace(helpchr_,"c","2")
helpchr_=Replace(helpchr_,"d","3")
helpchr_=Replace(helpchr_,"e","4")
helpchr_=Replace(helpchr_,"f","5")
helpchr_=Replace(helpchr_,"g","6")
helpchr_=Replace(helpchr_,"h","7")
helpchr_=Replace(helpchr_,"i","8")
helpchr_=Replace(helpchr_,"j","9")

getasc=replace(helpchr_," ","")
end function

%>

<% response.write getasc("我是谁") %>
</body>
</html>

原创粉丝点击