用asp判断字符串中是否含有汉字

作者在 2006-06-03 02:51:00 发布以下内容

<%
dim str
str="中国2008"
if Len(Hex(asc(str)))>2 then
    response.write("字符串中含有汉字")
else
    response.write("字符串中没有汉字")
end if
%>

WEB开发 | 阅读 5901 次
文章评论,共4条
leon2
2006-07-30 23:50
1
Asc 不是只能返回字符串的第一个字符的 Ascii 值吗?我要是 str="2008中国"呢?
静夜思(作者)
2007-03-03 06:45
2
抱歉,疏忽了
<%
dim str,i,out
str="2008中国"
out="字符串中没有汉字"
for i=1 to len(str)
    if asc(mid(str,i,1))<0 then
        out="字符串中含有汉字"
    end if
next
response.write out
%>
变幻小子
2011-03-22 22:25
3
你好&nbsp;&nbsp;路过看看
kingfangden
2014-01-22 21:22
4
学习了。
游客请输入验证码
浏览2800418次
文章归档