<%
'中文处理函数
sub ShowBody(Str)
dim result
dim l
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case chr(32) '处理空格符
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 chr(13) '处理回车符
result=result+"
"
case else
result=result+mid(str,i,1)
end select
next
response.write result
end sub
sub display(str)
if not isNULL(str) then
showbody str
end if
end sub
%>
引用的时候可以这样引用: 如你的代码读取出来赋于一变量:content 则这样引用:<%=ShowBody(content)%>就可以了。7.295227E-02
当然,还有一种相对于这个较简单的代码:7.295227E-02
<%
Function HtmlEncode(fstring)
fstring = Replace(fstring,Chr(32)," ")
fstring = Replace(fstring,Chr(9)," ")
fstring = Replace(fstring,Chr(39),"'")
fstring = Replace(fstring,Chr(10),"
")
fstring = Replace(fstring,Chr(10)&Chr(10),"")
fstring = Replace(fstring,Chr(34),""")
fstring = Replace(fstring,Chr(13),"")
HtmlEncode = fstring
End Function
%>
引用方法(情况如上):<%=HtmlEncode(content)%>就可以了
本文作者:佚名 来源:http://www.w3sky.com
CIO之家 www.ciozj.com 微信公众号:imciow