如果是要读数据库里的话:
v_content=replace(rs("正文"),chr(13),"<br>")
然后直接调用v_content,这样段落,空格就都可以实现了
[此贴子已经被作者于2006-6-16 15:08:20编辑过]
给你一个显示的函数吧
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+"<"
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
response.write result
end sub
调用的时候用:
<%ShowBody(Rs("正文"))%>就可以了。
<%
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
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(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 chr(9)
result=result+" "
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>
二、然后在后台录入页面这样做:
<!--#include file="htmlencode2.asp"-->
.....................................................
... '数据库链接字段
rs("content")=htmlencode2(request("content"))
三、读出页面这样做:
<%
dim content
content=replace(rs("content"),"<br>",chr(13))
content=replace(content," "," ")
response.write content
%>
最后:得到上面我说的情况,盼老师解答!谢谢!