你好,欢迎访问远方教程PC版!
广告位招租
网站首页 >> ASP教程 >> ASP优化技巧 >> 文章内容

ASP从汉字中提取出拼音首字母的方法

[日期:2015-02-24]   来源:远方教程  作者:远方教程   阅读:3955次[字体: ] 访问[旧版]
 捐赠远方教程 

    想做一个利用拼音的检索程序,还没想出来,但是却无意间实现了怎样从汉字中获取拼音首字母的程序,分享给大家。

<%
'返回汉字拼音首字母串
Function getpychar(char)
getpychar = ""
Dim charLen,chrInt,tmpp,pychar
charLen = Len(char)
If charLen < 1 Then Exit Function
For chrInt = 1 To charLen
tmpp=65536+asc(Mid(char,chrInt,1))
If(tmpp>=45217 And tmpp<=45252) Then
 pychar= "A"
ElseIf(tmpp>=45253 And tmpp<=45760) Then
 pychar= "B"
ElseIf(tmpp>=45761 And tmpp<=46317) Then
 pychar= "C"
ElseIf(tmpp>=46318 And tmpp<=46825) Then
 pychar= "D"
ElseIf(tmpp>=46826 And tmpp<=47009) Then
 pychar= "E"
ElseIf(tmpp>=47010 And tmpp<=47296) Then
 pychar= "F"
ElseIf(tmpp>=47297 And tmpp<=47613) Then
 pychar= "G"
ElseIf(tmpp>=47614 And tmpp<=48118) Then
 pychar= "H"
ElseIf(tmpp>=48119 And tmpp<=49061) Then
 pychar= "J"
ElseIf(tmpp>=49062 And tmpp<=49323) Then
 pychar= "K"
ElseIf(tmpp>=49324 And tmpp<=49895) Then
 pychar= "L"
ElseIf(tmpp>=49896 And tmpp<=50370) Then
 pychar= "M"
ElseIf(tmpp>=50371 And tmpp<=50613) Then
 pychar= "N"
ElseIf(tmpp>=50614 And tmpp<=50621) Then
 pychar= "O"
ElseIf(tmpp>=50622 And tmpp<=50905) Then
 pychar= "P"
ElseIf(tmpp>=50906 And tmpp<=51386) Then
 pychar= "Q"
ElseIf(tmpp>=51387 And tmpp<=51445) Then
 pychar= "R"
ElseIf(tmpp>=51446 And tmpp<=52217) Then
 pychar= "S"
ElseIf(tmpp>=52218 And tmpp<=52697) Then
 pychar= "T"
ElseIf(tmpp>=52698 And tmpp<=52979) Then
 pychar= "W"
ElseIf(tmpp>=52980 And tmpp<=53640) Then
 pychar= "X"
ElseIf(tmpp>=53689 And tmpp<=54480) Then
 pychar= "Y"
ElseIf(tmpp>=54481 And tmpp<=62289) Then
 pychar= "Z"
Else '如果不是中文,则不处理
 pychar= Mid(char,chrInt,1)
End If
getpychar = getpychar & pychar
Next
End function
%>

图片展示
 
相关评论
站长推荐