<%
Function DealInput(exp1)
dim exp2
exp2=Replace(exp1,"<","&lt;")
exp2=Replace(exp2,">","&gt;")
exp2=Replace(exp2,"'","'")
DealInput=exp2
End Function

Function Dealoutput(exp1)
dim exp2
exp2=Replace(exp1,"&gt;",">")
exp2=replace(exp2,"&lt;","<")
exp2=Replace(exp2,"<br>",chr(10))
exp2=Replace(exp2,"<p>",chr(13))
exp2=replace(exp2,"&quot;",chr(34))
exp2=replace(exp2,"</p>",chr(13))
exp2=replace(exp2,"&amp;","&")
Dealoutput=exp2
End Function

function formatnews(str)

    dim result
    dim l
    l=len(str)
    result=""
	dim i
	for i = 1 to l
	    select case mid(str,i,1)
	           case "<br>"
	                result=result&chr(13)
	           case "&gt;"
					result=result&">"
				case "&lt;"
					result=result&"<"
				case "&quot;"
					result=result&chr(34)
				case "&amp;"
					result=result&"&"
	           case "<p>"
	                result=result&chr(13)
	           case "</p>"
	                result=result&chr(13)
	           case else
	                result=result&mid(str,i,1)
         end select
     next 
     formatnews=result
end function


Function formatoutput(exp1)
dim exp2
exp2=Replace(exp1,"<br>",chr(10))
exp2=Replace(exp2,"<p>",chr(13))
formatoutput=exp2
End Function

   sub ShowBody(Str)
    dim result
    dim l
    l=len(str)
    result=""
	dim i
	for i = 1 to l
	    select case mid(str,i,1)
	           case "<"
	                result=result+"&lt;"
	           case ">"
	                result=result+"&gt;"
	           case chr(34)
	                result=result+"&quot;"
	           case "&"
	                result=result+"&amp;"
	           case chr(13)
	                result=result+"<br>"
	           case chr(9)
	                result=result+""
	           case chr(32)	           
	                'result=result+"&nbsp;"
	                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 
       response.write result
   end sub

   sub display(str)
     if not isNULL(str) then 
           showbody str
     end if
   end sub
   
   function display2(str)
    dim result
    dim l
    l=len(str)
    result=""
	dim i
	for i = 1 to l
	    select case mid(str,i,1)
	           case "<"
	                result=result+"&lt;"
	           case ">"
	                result=result+"&gt;"
'	           case "'"     
'					result=result+"''"
	           case chr(34)
	                result=result+"&quot;"
	           case "&"
	                result=result+"&amp;"
	           case chr(13)
	                result=result+"<br>"
	           case chr(9)
	                result=result+"		"
	           case chr(32)	           
	                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+"&nbsp;"
	                   else
	                      result=result+"&nbsp;"
	                   end if
	                else
	                   result=result+""	                    
	                end if
	           case else
	                result=result+mid(str,i,1)
         end select
       next 
       display2=result   
   end function
%>