Common/Text.cs

(开头部分) 26KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Configuration;

/// <summary>
/// 常用文本处理方法
/// </summary>
public class Text
{
    

    #region 过滤脏词 public static string ShitEncode(string s)
    /// <summary>
    /// 过滤脏词,默认有为“妈的|你妈|他妈|妈b|妈比|fuck|shit|我日|法轮|我操”
    /// 可以在 bbs.config 里设置 BadWords 的值
    /// </summary>
    public static string ShitEncode(string s)
    {
        string bw = ConfigHelper.GetConfigString("BadWords");
        if (bw == null || 0 == bw.Length)
        {
            bw = "妈的|你妈|他妈|妈b|妈比|fuck|shit|我日|法轮|我操";
        }
        else
        {
            bw = Regex.Replace(bw, @"\|{2,}", "|");
            bw = Regex.Replace(bw, @"(^\|)|(\|$)", string.Empty);
        }
        return Regex.Replace(s, bw, "**", RegexOptions.IgnoreCase);
    }
    #endregion


    #region 文本编码 	public static string TextEncode(string s)
    /// <summary>
    /// 文本编码
    ///</summary>
    public static string TextEncode(string s)
    {
        if (null == s || 0 == s.Length)
        {
            return string.Empty;
        }

        StringBuilder sb = new StringBuilder(s);
        sb.Replace("&", "&amp;");
        sb.Replace("<", "&lt;");
        sb.Replace(">", "&gt;");
        sb.Replace("\"", "&quot;");
        sb.Replace("\'", "&#39;");
        return ShitEncode(sb.ToString());
    }
    #endregion


    #region HTML 编码 public static string HtmlEncode(string s)
    /// <summary>
后面还有 824 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。