zoukankan      html  css  js  c++  java
  • 过滤HTML 字符串,原来字符串

    using System;
    //using System.Text;
    namespace SCard
    {
    /// <summary>
    /// CleanString 的摘要说明。
    /// </summary>
    public sealed class CleanString
    {
      public static string htmlInputText( string inputString )//HTML过滤输入字符串
      {
       if ((inputString != null) && (inputString != String.Empty ))
       {
        inputString = inputString.Trim();
        inputString = inputString.Replace("'","&quot;");
        inputString = inputString.Replace("<","&lt;");
        inputString = inputString.Replace(">","&gt;");
        inputString = inputString.Replace(" ","&nbsp;");
        inputString = inputString.Replace("\n","<br>");
        return inputString.ToString();
       }
       return "";
      }
      public static string htmlOutputText( string inputString )//HTML还原字符串
      {
       if ((inputString != null) && (inputString != String.Empty ))
       {
        inputString = inputString.Trim();
        inputString = inputString.Replace("&quot;","'");
        inputString = inputString.Replace("&lt;","<");
        inputString = inputString.Replace("&gt;",">");
        inputString = inputString.Replace("&nbsp;"," ");
        inputString = inputString.Replace("<br>","\n");
        return inputString.ToString();
       }
       return "";
      }
    }
    }
  • 相关阅读:
    1052 卖个萌
    编程实现hdfs对文件的操作
    关于Eclipse编译运行MapReduce程序报错问题的解决
    用户模板和用户场景
    用户体验评价
    大二下学期软件工程课程总结
    教师派第二阶段10
    教师派第二阶段09
    教师派第二阶段07
    教师派第二阶段06
  • 原文地址:https://www.cnblogs.com/MySpace/p/1599682.html
Copyright © 2011-2022 走看看