兄弟们,救急啊,帮帮我

tantaiyizu 2008-06-20 12:39:06

'/**************************************************
' * 字符串处理类
' * 2008-6-14
' **************************************************
'**************************************************/

' <summary>
' 过滤html为text
' </summary>
'<param name="text">字符串</param>
'<param name="full">是否是过滤html标签</param>
Function HTML2Text(text ,full)
Dim temp
temp = text
temp = Replace(temp ," " ," ")
temp = Replace(temp ,Chr(10) ,"<br />")
temp = Replace(temp ,"'" ,"'")
If full <> 1 And full <> True Then
temp = Replace(temp ,"<" ,"<")
temp = Replace(temp ,">" ,">")
End If

HTML2Text = temp
End Function

' <summary>
' 还原text为html
' </summary>
'<param name="html">html数据</param>
Function Text2HTML(html)
Dim temp
temp = html
tmep = Replace(temp ,"<br />" ,Chr(10))
temp = Replace(temp ," " ," ")
temp = Replace(temp ,"'" ,"'")
temp = Replace(temp ,"<" ,"<")
temp = Replace(temp ,">" ,">")

Text2HTML = temp
End Function



我写的上述代码就是为了处理一些字符 ,可是回车和换行的时候总是不行啊 。。

大家在asp中处理回车换行有什么心得或者代码? 拿出来能分享下吗?(我用的textarea)
帮帮忙,谢谢大家了
...全文
608 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
renjun24 2008-06-22
  • 打赏
  • 举报
回复
痴情客,你也会犯这种低级错误啊,仔细点吧
tantaiyizu 2008-06-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 gingerkang 的回复:]
replace(str,vbcrlf," <br>")
[/Quote]

可我的怎么不行呢?

每次 vbcrlf 就多出一个 <br /> 来 ,很奇怪 ,不知道为什么?
sy_binbin 2008-06-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 gingerkang 的回复:]
replace(str,vbcrlf," <br>")
[/Quote]
gingerkang 2008-06-20
  • 打赏
  • 举报
回复
replace(str,vbcrlf,"<br>")
tantaiyizu 2008-06-20
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 gingerkang 的回复:]
我现在不用逆过程,用户输入什么就把什么入库,不刻意转化代码,在页面输出的时候根据需要再做类似ubb的转化
[/Quote]

输出的时候你怎么把 回车或换行 转为 <br /> 呢?
gingerkang 2008-06-20
  • 打赏
  • 举报
回复
我现在不用逆过程,用户输入什么就把什么入库,不刻意转化代码,在页面输出的时候根据需要再做类似ubb的转化
xiaojing7 2008-06-20
  • 打赏
  • 举报
回复
痴情客做什么?..........
tantaiyizu 2008-06-20
  • 打赏
  • 举报
回复
我怎么就没注意那些细节呢?

和恶化
tantaiyizu 2008-06-20
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 gingerkang 的回复:]
tmep = Replace(temp , vbcrlf ," <br />")
=>temp = Replace(temp , vbcrlf ," <br />")
注意拼写
[/Quote]

呵呵 ,这位兄弟正解 ,谢谢大家

问题解决了


wdbjsh 2008-06-20
  • 打赏
  • 举报
回复
主意 回车和换行是两个概念

一个是chr(10)一个是chr(13)
gingerkang 2008-06-20
  • 打赏
  • 举报
回复
tmep = Replace(temp , vbcrlf ,"<br />")
=>temp = Replace(temp , vbcrlf ,"<br />")
注意拼写
shuizhilang 2008-06-20
  • 打赏
  • 举报
回复
rs("数据库字段")=HTML2Text(trim(reqeust("textarea"))) '保存到数据库


<textarea name="textarea"><%=Text2HTML(rs("数据库字段"))%></textarea> '从数据库中读取
tantaiyizu 2008-06-20
  • 打赏
  • 举报
回复
晕的了 ,怎么就没人呢?
tantaiyizu 2008-06-20
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 mingxuan3000 的回复:]


asp,vbscript都不会。。。
[/Quote]

还是谢谢你了,铭轩大侠


还有大侠吗? 快来啊
mingxuan3000 2008-06-20
  • 打赏
  • 举报
回复


asp,vbscript都不会。。。
tantaiyizu 2008-06-20
  • 打赏
  • 举报
回复

' <summary>
' 过滤html为text
' </summary>
'<param name="text">字符串</param>
'<param name="full">是否是过滤html标签</param>
Function HTML2Text(text ,full)
Dim temp
temp = text
temp = Replace(temp ," " ," ")
temp = Replace(temp ,"'" ,"'")
If full <> 1 And full <> True Then
temp = Replace(temp ,"<" ,"<")
temp = Replace(temp ,">" ,">")
End If

HTML2Text = temp
End Function

' <summary>
' 还原text为html
' </summary>
'<param name="html">html数据</param>
Function Text2HTML(html)
Dim temp
temp = html
tmep = Replace(temp , vbcrlf ,"<br />")
temp = Replace(temp ," " ," ")
temp = Replace(temp ,"'" ,"'")
temp = Replace(temp ,"<" ,"<")
temp = Replace(temp ,">" ,">")

Text2HTML = temp
End Function


经过大家的指点 ,我改成上面的了

比如我输入:

asd
asda
asd
asd
asd

这样的时候我去调用 HTML2Text ,是不做回车换行替换的

然后我输出的时候调 Text2HTML 去显示 ,可怎么还是不行呢?

拜托大家了

28,390

社区成员

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

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