CHAR.INC
上传用户:shxinnian
上传日期:2013-01-14
资源大小:155k
文件大小:1k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

Windows_Unix

  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 chr(13)
  15.                 result=result+"<br>"
  16.            case chr(34)
  17.                 result=result+"&quot;"
  18.               case chr(32)            
  19.                 'result=result+"&nbsp;"
  20.                 if i+1<=l and i-1>0 then
  21.                    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                       
  22.                       result=result+"&nbsp;"
  23.                    else
  24.                       result=result+" "
  25.                    end if
  26.                 else
  27.                    result=result+"&nbsp;"                     
  28.                 end if
  29.            case chr(9)
  30.                 result=result+"    "
  31.            case else
  32.                 result=result+mid(str,i,1)
  33.          end select
  34.        next 
  35.        htmlencode2=result
  36.    end function
  37. %>