耐水腻子施工工艺:请高手帮助看下ASP代码,在线等,多谢

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 03:03:26
您好,我是ASP初学者,下面这段代码我实在头痛,看不明白。麻烦哪位高手帮我加个注释,告诉我这段代码是干什么的。特别是for next 语句里面的代码

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
楼下解释的不够详细,我还是不了解。麻烦再详细点,多谢。特别是for next里面的

就是一个把文字域控件输入的值转换为HTML编码的函数,比如输入一个回车,就输出一个<br> for 里面是从输入的字符里一个个读取然后判断处理的循环(以mid(字符,位数,1)方式)

加我QQ,现在忙,没时间解释
55967659