请问诸位大哥怎样才能将存在数据库中的文本正文按照正确的格式在网页上显示出来,高分相送

littlespring 2003-02-18 04:32:14
怎样才能将存在数据库中的文本正文按照正确的格式在网页上显示出来,高分相送
...全文
26 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hchxxzx 2003-02-18
  • 打赏
  • 举报
回复
你是不是把WORD写到数据库中去?
如果是,那只要把WORD读取出来就可以正确显示了
如果不是,用以下这个函数转换一下就可以了

先把值求出来,再按照下面的函数转换一下
function my_newline(str)
if str<>"" then
my_newline=replace(str,chr(13)&chr(10),"<br>")
my_newline=replace(my_newline,chr(32)," ")
my_newline=replace(my_newline,chr(9),"  ")
else
my_newline=" "
end if
end function

response.write my_newline(rs("xxx"))
littlespring 2003-02-18
  • 打赏
  • 举报
回复
先谢了
这位大哥我还有点不太明白,怎么将Word文本读到这个函数中呢
meizz 2003-02-18
  • 打赏
  • 举报
回复
在入库之前对存入的文字进行一次转换:

<%
Function coder(str)
Dim result,L,i
If IsNull(str) Then : coder="" : Exit Function : End If
L=Len(str) : result=""
For i = 1 to L
select case mid(str,i,1)
case "<" : result=result+"<"
case ">" : result=result+">"
case "&" : result=result+"&"
case chr(9) : result=result+"    "
case chr(13) : result=result+"<br>"
case chr(32) : result=result+" "
case chr(34) : result=result+"""
case chr(39) : result=result+"'"
case else : result=result+mid(str,i,1)
end select
Next
coder=result
End Function
%>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧