Online ASP Advanced article online Management Update--The transformation of HTM code
Author: Beach Boy
In front of the article for you to introduce the online add and save, but if this is not enough, because a lot of the article itself with the HTM code must be fully displayed, rather than show its effect, which means that the HTM code must be transformed to enable it to specifically display its code, such as: <a href= "" > Hello </a> you do not want to show on the page that it is a connection, but rather display its code, which is like FrontPage directly in the editing page to write code, but FrontPage provides the function of transformation.
In the ASP, you can transform the specific HTM code, so that it can be displayed in a complete form, such as the general format of HTM <> and so on, there is the ASP display HTM code format to be converted to HTM code, such as in the ASP Chr (13) for carriage return, then it must be translated into <br>, because in addition to the content of the article when all the newline and space in the return to savearticle.asp after the code is expressed in ASP, so this time to convert it to the HTM code, the only way to make the article correctly displayed.
The following is the system of these code conversion procedures, in which I have detailed the note marked
Create a new file Articlechar.inc with the following details:
<%
"A function program is built into a group processing function in the subroutine process and is a stand-alone program that accepts arguments to execute a series of code statements, and returns the knot of the processed code statement directly to the user code.
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
"To determine the contents of the return, and to include <,>,CHR (a), Chr (a), &,CHR (), Chr (9) for the corresponding conversion, such as CHR (13) into <br>; is the HTM code of carriage return
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 or mid (str,i+1,1) =CHR (9) or mid (str,i-1,1) =CHR (?) 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
%>
After the article returned to the information processing, the article can be displayed normally, so the next section will show how to display the article, automatically generate the HTM page of the article.
Reprint please indicate the source http://asky.on.net.cn