【问题标题】:Show whitespace instead of   after HTMLEncode在 HTMLEncode 之后显示空格而不是  
【发布时间】:2016-12-16 20:52:48
【问题描述】:

查看一个旧的 ASP 文件,我试图找出实现以下目标的最佳做法:
我通过数据库连接收到string
此字符串是选择框的显示部分。
我需要使用Server.HTMLEncode(string) 输出此字符串。 但是,由于该字符串中有空格,我得到的输出为 

  转换回实际空白的最佳做法是什么?

【问题讨论】:

  • 你可以使用replace(" "," ")
  • 它应该可以工作
  • 不幸的是,这给了我一个运行时错误“800a01a8”。
  • 查看此网址stackoverflow.com/questions/3708734/…,可替换(" ","")
  • 由于使用经典的 asp - 而不是 asp.net ^^

标签: asp-classic html-encode


【解决方案1】:

为了在经典 ASP 中用空格替换  ,我使用了以下代码:

<%= Replace(Server.HTMLEncode(string),"&nbsp;"," ") %>

其中string 是包含&amp;nbsp; 的变量。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-24
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    • 1970-01-01
    • 2010-09-28
    • 1970-01-01
    • 2013-04-04
    相关资源
    最近更新 更多