3 回答

TA貢獻1794條經驗 獲得超8個贊
<%
function rp(string)
dim str
str=replace(string,chr(34),"&quot;")
str=replace(str,chr(38),"&amp;")
str=replace(str,chr(39),"&#39;")
str=replace(str,"<","&lt;")
str=replace(str,">","&gt;")
str=replace(str,chr(32),"&nbsp;")
str=replace(str,chr(10),"<br>")
str=replace(str,chr(13),"")
rp=str
end function
function nrp(string)
dim str
str=replace(string,"&quot;",chr(34))
str=replace(str,"&#39;",chr(39))
str=replace(str,"&lt;","<")
str=replace(str,"&gt;",">")
str=replace(str,"&nbsp;",chr(32))
str=replace(str,"<br>",chr(13)&chr(10))
str=replace(str,"&amp;",chr(38))'注意這一句必須放在最后,否則就像樓上的那樣,會出現意想不到的結果?
nrp=str
end function
%>
把以上的&符號替換為英文狀態下的&

TA貢獻1815條經驗 獲得超10個贊
Function rp(s)
Dim t
t = Replace(s, "&", "&")
t = Replace(t, "<", "<")
t = Replace(t, ">", ">")
t = Replace(t, " ", " ")
t = Replace(t, vbcrlf, "<br>") '這個是Windows換行符,vbcrlf
rp = t
End Function
Function nrp(s)
Dim t
t = Replace(s, "&", "&")
t = Replace(t, "<", "<")
t = Replace(t, ">", ">")
t = Replace(t, " ", " ")
t = Replace(t, "<br>", vbcrlf)
nrp = t
End Function
添加回答
舉報