求救:如何将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

%>

Function HTMLEncode(reString)

Dim Str:Str=reString

If Not IsNull(Str) Then

Str = UnCheckStr(Str)

Str = Replace(Str, "&", "&")

Str = Replace(Str, ">", ">")

Str = Replace(Str, "<", "<")

Str = Replace(Str, CHR(32), " ")

Str = Replace(Str, CHR(9), "")

Str = Replace(Str, CHR(9), "")

Str = Replace(Str, CHR(34),""")

Str = Replace(Str, CHR(39),"'")

Str = Replace(Str, CHR(13), "")

Str = Replace(Str, CHR(10), "<br>")

HTMLEncode = Str

End If

End Function

isnull函数的用法:

将被检查是否为 NULL的表达式。check_expression 可以是任何类型的。

在 check_expression 为 NULL时将返回的表达式。replacement_value 必须返回与check_expresssion 具有相同的类型。

扩展资料

补充:

在 check_expression 为 NULL时返回与 check_expression 相同的类型。

如果 check_expression 不为 NULL,那么返回该表达式的.值;否则返回 replacement_value。

IsNull,计算机语言函数,意思是返回 Boolean 值,指明表达式是否不包含任何有效数据 (Null)。

使用 IsNull 函数可以判断表达式是否包含 Null 值。在某些情况下想使表达式取值为 True,例如 IfVar=Null 和 IfVar<>Null,但它们通常总是为 False。这是因为任何包含 Null 的表达式本身就为 Null,所以表达式的结果为 False。


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存