zoukankan      html  css  js  c++  java
  • HTML特殊字符数据库读写处理

     [写进数据库时调用]
    '<script language='javascript'>
            '<!--///用户前台aspx提交时///
            '// 替换特殊字符
            'function HTMLEncode(text)
            '{
            ' text = text.replace(/&/g, "&amp;") ;
            ' text = text.replace(/"/g, "&quot;") ;
            ' text = text.replace(/</g, "&lt;") ;
            ' text = text.replace(/>/g, "&gt;") ;
            ' text = text.replace(/'/g, "’") ;
            ' text = text.replace(/\ /g,"&nbsp;");
            ' text = text.replace(/\n/g,"<br>");
            ' text = text.replace(/\t/g,"&nbsp;&nbsp;&nbsp;&nbsp;");   
            ' return text;
            '}
            '//-->
            '</script>

    [数据读取时调用]
      Public Shared Function TextToHtml() As String
            If _Text <> Nothing Then
                _Text = _Text.Replace("&lt;", "<")
                _Text = _Text.Replace("&gt;", ">")
                _Text = _Text.Replace("&nbsp;", Chr(32))
                _Text = _Text.Replace("’", "'")
                _Text = _Text.Replace("&quot;", ControlChars.Quote)
                '//_Text = _Text.Replace("&amp;", "&")
                _Text = _Text.Replace("<br>", Chr(13))
                Return _Text
            Else
                Return Nothing
            End If
        End Function
  • 相关阅读:
    css样式学习笔记
    Css教程玉女心经版本
    weblogic高级进阶之ssl配置证书
    weblogic高级进阶之查看日志
    weblogic之高级进阶JMS的应用
    【WebLogic使用】3.WebLogic配置jndi数据源
    shiro的helloworld
    尚硅谷spring 事物管理
    尚硅谷spring aop详解
    Spring Boot 2.x Redis多数据源配置(jedis,lettuce)
  • 原文地址:https://www.cnblogs.com/ding0910/p/398686.html
Copyright © 2011-2022 走看看