Function 此函数是否在中添加空格?
我们有一个网站,它有很多有用的函数,都是由我们的第三方程序员编写的,但是最近,我注意到其中一个函数在运行时似乎放了一个空格,但我似乎找不到它的位置来删除它 该函数称为“formatspecialcharacters”。它的功能是获取一个字符串并查看它,以将字符串中的特殊字符更改为HTML实体,并编写为:Function 此函数是否在中添加空格?,function,asp-classic,Function,Asp Classic,我们有一个网站,它有很多有用的函数,都是由我们的第三方程序员编写的,但是最近,我注意到其中一个函数在运行时似乎放了一个空格,但我似乎找不到它的位置来删除它 该函数称为“formatspecialcharacters”。它的功能是获取一个字符串并查看它,以将字符串中的特殊字符更改为HTML实体,并编写为: function formatspecialcharacters(stringtoformat) formatspecialcharacters = "" if isblank(string
function formatspecialcharacters(stringtoformat)
formatspecialcharacters = ""
if isblank(stringtoformat) then exit function
stringtoformat = CStr(stringtoformat)
stringtoformat = Trim(stringtoformat)
fieldcontents = HTMLDecode(stringtoformat)
if Len(fieldcontents)>0 then
for character_i = 1 to Len(fieldcontents)
character_c = asc(mid(fieldcontents, character_i, 1))
select case character_c
case 174, 169
formatspecialcharacters = formatspecialcharacters & "<sup>" & chr(character_c) & "</sup>"
case else
formatspecialcharacters = formatspecialcharacters & chr(character_c)
end select
next
end if
end function
Function HTMLDecode(sText)
sText = vbcrlf & vbtab & sText
Dim I
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, Chr(62) , Chr(62) & vbcrlf & vbtab)
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, " ", Chr(32))
sText = Replace(sText, Chr(147), Chr(34)) 'smart quotes to proper quotes
sText = Replace(sText, Chr(148), Chr(34))
sText = Replace(sText, Chr(146), Chr(39)) 'smart apostrophe to proper apostrophe
For I = 1 to 255
sText = Replace(sText, "&#" & I & ";", Chr(I))
Next
HTMLDecode = sText
End Function
我想它可能在第二个函数中,因为当我这样使用它时:
<a href="<%=decendentdocumentformat_filename(j)%>"><%=formatspecialcharacters(decendentdocumentformat_label(j))%></a>
其中“DecentDocumentFormat\u文件名(j)”=“/example.html”
和“formatspecialcharacters(DecentDocumentFormat\u标签(j))”=“网页”
在本例中,当它呈现时,我有一个链接,后跟一个空格,然后是标签(在本例中是“网页”),当它应该是链接时,然后是标签,两者之间没有空格
任何帮助都会很好。提前谢谢。不是100%确定我会遵守,但如果你愿意的话
<p><%=formatspecialcharacters("AAA") %><%=formatspecialcharacters("BBB") %></p>
你会看到一个空间AAA BBB
因为HTMLDecode
要做的第一件事是在输入字符串前加上回车/换行&选项卡,浏览器将其显示为空白
如果不想删除可见空间,请删除sText=vbcrlf&vbtab&sText
(另外,输入在
HTMLDecode
之后不会被修剪,因此如果它被传递“XXX
”,您将有一个尾随空格)不是100%确定我是否遵循,但如果您遵循
<p><%=formatspecialcharacters("AAA") %><%=formatspecialcharacters("BBB") %></p>
你会看到一个空间AAA BBB
因为HTMLDecode
要做的第一件事是在输入字符串前加上回车/换行&选项卡,浏览器将其显示为空白
如果不想删除可见空间,请删除sText=vbcrlf&vbtab&sText
(另外,输入在
HTMLDecode
之后不会被修剪,因此如果它被传递“XXX
”,您将有一个尾随空格)非常感谢,完成了!非常感谢,成功了!