首页  ·  知识 ·  编程语言
让从数据保持原来的格式
佚名  http://www.w3sky.com  ASP  编辑:dezai  图片来源:网络
% '中文处理函数 sub ShowBody(Str) dim result dim l l=len(str) result="" dim i for i = 1 to l s
<%
    '中文处理函数
    sub ShowBody(Str)
    dim result
    dim l 
    l=len(str)
    result=""
    dim i
    for i = 1 to l
    select case mid(str,i,1)
    case chr(32)     '处理空格符
    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 chr(13) '处理回车符
    result=result+"
" case else result=result+mid(str,i,1) end select next response.write result end sub sub display(str) if not isNULL(str) then showbody str end if end sub %>

引用的时候可以这样引用: 如你的代码读取出来赋于一变量:content 则这样引用:<%=ShowBody(content)%>就可以了。7.295227E-02

当然,还有一种相对于这个较简单的代码:7.295227E-02

<%
    Function HtmlEncode(fstring)
	fstring = Replace(fstring,Chr(32)," ")
    fstring = Replace(fstring,Chr(9)," ")
    fstring = Replace(fstring,Chr(39),"'")
    fstring = Replace(fstring,Chr(10),"
") fstring = Replace(fstring,Chr(10)&Chr(10),"

") fstring = Replace(fstring,Chr(34),""") fstring = Replace(fstring,Chr(13),"") HtmlEncode = fstring End Function %>

引用方法(情况如上):<%=HtmlEncode(content)%>就可以了

本文作者:佚名 来源:http://www.w3sky.com
CIO之家 www.ciozj.com 微信公众号:imciow
   
免责声明:本站转载此文章旨在分享信息,不代表对其内容的完全认同。文章来源已尽可能注明,若涉及版权问题,请及时与我们联系,我们将积极配合处理。同时,我们无法对文章内容的真实性、准确性及完整性进行完全保证,对于因文章内容而产生的任何后果,本账号不承担法律责任。转载仅出于传播目的,读者应自行对内容进行核实与判断。请谨慎参考文章信息,一切责任由读者自行承担。
延伸阅读