我将hchxxzx(独自前行)函数改了一下:
function get_str(str)
get_str=replace(str,vbcrlf,"<br>")
get_str=replace(get_str,chr(10)," ")
end function
据小弟观查,提交表单时,除手动添加的空格其它空格被忽略.
如果要保持完整的模样,可以这样:
function get_str(str)
get_str=replace(str,chr(13),"<br>")
get_str=replace(get_str,chr(10)," ")
end function
要用的时候调用一下这个函数,就可以完整的将段落及首行的空格替换出来。
<% function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l '对返回的内容进行判定,并对其含有<,>,chr(13),chr(34),&,chr(32),chr(9)进行相应的转化,如chr(13)变为<BR> 也就是回车的HTM代码
select case mid(str,i,1)
case "<" result=result+"<"
case ">" result=result+">"
case chr(13) result=result+"<br>"
case chr(34) result=result+"""
case "&" result=result+"&"
case chr(32) result=result'+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else result=result+" "
end if
else result=result+" "
end if
case chr(9) result=result+" "
case else result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>