While not InStr(i,Tekst_temp,"{") = 0
start = CInt( InStr(1,Tekst_temp,"{") )
i = start
slutt = CInt( InStr(start,Tekst_temp,"}") )
hole = mid(Tekst_temp,(start),(slutt-start+1))
if InStr(hole,"$") then
skille = CInt( InStr(start,Tekst_temp,"$") )
navn = mid(Tekst_temp,(start+1),(skille-start-1))
link = mid(Tekst_temp,(skille+1),(slutt-skille-1))
if Left(link,4) = "www." then
link = "http://" & link
end if 'www
if not InStr(link,"@") = 0 then
link = "mailto:" & link
end if '@
out_var = "<A HREF=""" & link & """>" & navn & "</A>"
Tekst_temp = Replace(Tekst_temp,hole,out_var,1,1)
else
link = mid(Tekst_temp,(start+1),(slutt-start-1))
if Left(link,4) = "www." then
link = "http://" & link
end if 'www
if not InStr(link,"@") = 0 then
link = "mailto:" & link
end if '@
link = "<A HREF=""" & link & """>"
Tekst_temp = Replace(Tekst_temp,"{",link,1,1)
Tekst_temp = Replace(Tekst_temp,"}","</A>",1,1)
end if
wend
<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
'case "<"
' result=result+"<"
'case ">"
' result=result+">"
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>
function htmlencode(str)
on error resume next
dim result
dim l
if isnull(str) then
htmlencode=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case "<"
result=result+"<"
case ">"
result=result+">"
case chr(34)
result=result+"""
case "&"
result=result+"&"
case chr(13)
result=result+"<br>"
case chr(9)
result=result+" "
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case else
result=result+mid(str,i,1)
end select
next
if err.number<>0 then err.clear
htmlencode=result
end function
试试我的函数
Function LeftTrue(str,n)
If len(str)<=(n+2)/2 Then
LeftTrue=str
Else
Dim TStr
Dim l,t,c
Dim i
l=len(str)
t=l
TStr=""
t=0
for i=1 to l
c=asc(mid(str,i,1))
If c<0 then c=c+65536
If c>255 then
t=t+2
Else
t=t+1
End If
If t>n Then exit for
TStr=TStr&(mid(str,i,1))
next
LeftTrue = TStr&"..."
End If
End Function