ASP常用函数:getpy()

2018-09-06 13:11

阅读:548

  <%
取字段数据每个汉字的拼音首字母

Functiongetpychar(char)
tmp=65536+Asc(char)
If(tmp>=45217Andtmp<=45252)Then
getpychar=A
ElseIf(tmp>=45253Andtmp<=45760)Then
getpychar=B
ElseIf(tmp>=47761Andtmp<=46317)Then
getpychar=C
ElseIf(tmp>=46318Andtmp<=46825)Then
getpychar=D
ElseIf(tmp>=46826Andtmp<=47009)Then
getpychar=E
ElseIf(tmp>=47010Andtmp<=47296)Then
getpychar=F
ElseIf(tmp>=47297Andtmp<=47613)Then
getpychar=G
ElseIf(tmp>=47614Andtmp<=48118)Then
getpychar=H
ElseIf(tmp>=48119Andtmp<=49061)Then
getpychar=J
ElseIf(tmp>=49062Andtmp<=49323)Then
getpychar=K
ElseIf(tmp>=49324Andtmp<=49895)Then
getpychar=L
ElseIf(tmp>=49896Andtmp<=50370)Then
getpychar=M
ElseIf(tmp>=50371Andtmp<=50613)Then
getpychar=N
ElseIf(tmp>=50614Andtmp<=50621)Then
getpychar=O
ElseIf(tmp>=50622Andtmp<=50905)Then
getpychar=P
ElseIf(tmp>=50906Andtmp<=51386)Then
getpychar=Q
ElseIf(tmp>=51387Andtmp<=51445)Then
getpychar=R
ElseIf(tmp>=51446Andtmp<=52217)Then
getpychar=S
ElseIf(tmp>=52218Andtmp<=52697)Then
getpychar=T
ElseIf(tmp>=52698Andtmp<=52979)Then
getpychar=W
ElseIf(tmp>=52980Andtmp<=53640)Then
getpychar=X
ElseIf(tmp>=53689Andtmp<=54480)Then
getpychar=Y
ElseIf(tmp>=54481Andtmp<=62289)Then
getpychar=Z
Else如果不是中文,则不处理
getpychar=char
EndIf
EndFunction

Functiongetpy(Str)
Fori=1ToLen(Str)
getpy=getpy&getpychar(Mid(Str,i,1))
Next
EndFunction
%>


评论


亲,登录后才可以留言!