求救:如何将HTML代码转化ASCII值?????

求救:如何将HTML代码转化ASCII值?????,第1张

自己写的两个函数,借你用一下,觉得好再加分,嘿嘿

储存时:

<%

function HtmlEncode(str)

on error resume next

Dim result,L

if isnull(str) then

HtmlEncode=""

Exit function

end if

L=len(str)

Dim i

for i=1 to L

select case mid(str,i,1)

case "<"

result=result&"<"

case ">"

result=result&">"

case "&"

result=result&"&"

case "'"

result=result&"''"

case chr(13)

result=result&"<BR>"

case chr(9)

result=result&"    "

case chr(32)

if i+1<=L and i-i>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

end if

HtmlEncode=result

end function

%>

也就是把HTML标准后再存入数据库

需要现在是编辑框之前,先用以下函数:

<%

function HtmlDecode(str)

on error resume next

str=replace(str,"<","<")

str=replace(str,">",">")

str=replace(str,"&","&")

str=replace(str,"<BR>",chr(13))

str=replace(str," ",chr(32))

if err.number<>0 then

err.clear

end if

HtmlDecode=str

end function

%>

都是,一个html页面里面包括这些标记

html是整个页面的标记

head是页面头的标记

title是标题的标记

body是页面内容的标记


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6097922.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-14
下一篇 2023-03-14

发表评论

登录后才能评论

评论列表(0条)

保存