<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<% dim TempStr,TDStr
dim Starti
'计算字符串长度
function GetChinaStrLen(s)
dim i
dim Dlen
dim c,a
Dlen=0
for i=1 to len(s)
a=mid(s,i,1)
c=asc(a)
if c>=0 and c<=127 then
Dlen=Dlen+1
else
Dlen=Dlen+2
end if
next
GetChinaStrLen=Dlen
end function
'截取字符串为指定长度
function leftChinaStr(s,w)
dim i
dim Dlen
dim c,a
dim rStr
rStr=""
Dlen=0
for i=1 to len(s)
a=mid(s,i,1)
c=asc(a)
if c>=0 and c<=127 then
Dlen=Dlen+1
else
Dlen=Dlen+2
end if
if Dlen>w then
exit for
end if
rStr=rStr&a
next
leftChinaStr=rStr
end function
%>
<%
'截取rs("title")为指定长度
if rs("title")<>"" then
TempStr=rs("title")
Starti=GetChinaStrLen(TempStr)
if Starti<=30 then
TDStr=TempStr
else
TDStr=leftChinaStr(TempStr,30)
end if
end if
%>
'调用举例
<a href="business_show.asp?id=<%=rs("id" target=_blank)%>" title="<%=TempStr%>" target="_blank"><%=TDStr%></a>