动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Asp → 阅读文章

 转换html代码子程序

作者来源: 
阅读 5691 人次 , 2000-11-12 

   function htmlencode(str)
    on error resume next
    dim result
    dim l
    if isnull(str) then
       htmlencode=""
       exit function
    end if

    l=len(str)
    result=""
dim i
for i = 1 to l
    select case mid(str,i,1)
           case "<"
                result=result+"&lt;"
           case ">"
                result=result+"&gt;"
           case chr(34)
                result=result+"&quot;"
           case "&"
                result=result+"&amp;"
           case chr(13)
                result=result+"<br>"
           case chr(9)
                result=result+"&nbsp;&nbsp;&nbsp;&nbsp;"
           case chr(32)            
                'result=result+"&nbsp;"
                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+"&nbsp;"
                   else
                      result=result+" "
                   end if
                else
                   result=result+"&nbsp;"                     
                end if
           case else
                result=result+mid(str,i,1)
         end select
       next
       if err.number<>0 then err.clear
       htmlencode=result
   end function

以上资料由动网先锋(http://www.aspsky.net)整理制作,转载请说明出处!  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:简单的检查输入email是否合法程序
· 下一篇:判断文章中文字符数量
· ASP+页缓存OutputCache Duration用法(指定页面过时时间)
· 一个把数字转英文的实用程序
· ASP讲座之六:ASP与数据库(一)
· 一个分页代码例子
· 将汉字转换成汉语拼音的一段代码


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077