ASP回车换行的问题

来源:百度知道 编辑:UC知道 时间:2024/06/19 17:19:04
将文本域的多行的文本插入到数据库后,显示出的时候没有换行符,请问如何转换,是在插入前转换还是在显示的时候转换?我要现成代码。
就像这个,如何调用呢?
function UHTMLEncode(fString)
if not isnull(fString) then
fString = Replace(fString, " ", CHR(32))
fString = Replace(fString, " ", CHR(9))
fString = Replace(fString, """, CHR(34))
fString = Replace(fString, "'", CHR(39))
fString = Replace(fString, "", CHR(13))
fString = Replace(fString, "</P><P>", CHR(10)&CHR(10))
fString = Replace(fString, "<BR>", CHR(10))
UHTMLEncode = fString
end if
end function

噢我的天啊,太菜了,我居然不知道怎么调用。

下面这个就足够了:
插入前或插入后均可,但只需候调用一次就行了

Function HTMLDecode(s)

If Trim(s)<>"" Then

s = Replace(s, CHR(13),"<p> </p>") '#####3我晕!!!!你把这个换成回车符不就行了。这里面你换成什么就是什么,,,可以自定义啊,你写函数是为了什么???不是为了处理一些你想要的东西???
s = Replace(s, CHR(10),"<br />") '换行符
s = Replace(s, CHR(32)," ") '空格
s = Replace(s, CHR(9)," ") 'TAB键的空格

End If

HTMLDecode = s

End Function

楼上的 xsh_xgc 抄袭的可真够狠的啊!!!无语

Function HTMLDecode(s)

If Trim(s)<>"" Then

s = Replace(s, CHR(13),"<br />") '回车符
s = Replace(s, CHR(10),"<br />") '换行符
s = Replace(s, CHR(32)," ") '空格
s = Replace(s, CHR(9)," ") 'TAB键的空格

End If

HTMLDecode = s

End Function

调用:
<%
=UHTMLEncode(