Zhlw.com - 中华龙网

站长资讯通告:
搜索: 您的位置中华龙网 > 计算机网络 > 网络编程 > ASP技术 > 文章列表

转换html代码子程序

作者:bear  来源:转载  发布时间:2006-1-25 16:14:56
  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
 

        用户名: 验证码: 验证码,看不清楚?请点击刷新验证码 (注“”为必填内容。)


文章评论: [ 查看全部 ] 网友评论
关于本站 - 网站帮助 - 广告合作 - 友情连接 - 网站地图