articleCHAR.INC
上传用户:qyswxdl
上传日期:2013-06-01
资源大小:1373k
文件大小:1k
源码类别:

家庭/个人应用

开发平台:

ASP/ASPX

  1. <%
  2. function htmlencode2(str)
  3.     dim result
  4.     dim l
  5.     if isNULL(str) then 
  6.        htmlencode2=""
  7.        exit function
  8.     end if
  9.     l=len(str)
  10.     result=""
  11. dim i
  12. for i = 1 to l
  13.     select case mid(str,i,1)
  14.            case "<"
  15.                 result=result+"&lt;"
  16.            case ">"
  17.                 result=result+"&gt;"
  18.               case chr(13)
  19.                 result=result+"<br>"
  20.            case chr(34)
  21.                 result=result+"&quot;"
  22.            case "&"
  23.                 result=result+"&amp;"
  24.               case chr(32)            
  25.                 'result=result+"&nbsp;"
  26.                 if i+1<=l and i-1>0 then
  27.                    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                       
  28.                       result=result+"&nbsp;"
  29.                    else
  30.                       result=result+" "
  31.                    end if
  32.                 else
  33.                    result=result+"&nbsp;"                     
  34.                 end if
  35.            case chr(9)
  36.                 result=result+"    "
  37.            case else
  38.                 result=result+mid(str,i,1)
  39.          end select
  40.        next 
  41.        htmlencode2=result
  42.    end function
  43. %>