留言板 内容 格式

using System;
using System.Text;
using System.Web;

namespace Bas
{
 /// <summary>
 /// Summary description for BasFun.
 /// </summary>
 public class BasFun
 {
  public BasFun()
  {
  }

  public  string TextToHtml(string chr)
  {
   if (chr == null)
   {
    return "";
   }
            chr = chr.Replace(" ", "&nbsp;&nbsp;");
   chr = chr.Replace("<", "&lt;");
   chr = chr.Replace(">", "&gt;");
   chr = chr.Replace("\n", "<br>");
            chr = chr.Replace("\t", "&nbsp;&nbsp;&nbsp;");
            chr = chr.Replace("'","'");
   return chr;
  }

        public string HtmlToText(string chr)
        {
            if (chr == null)
            {
                return "";
            }
            chr = chr.Replace("&nbsp;", " ");
            chr = chr.Replace("&lt;", "<");
            chr = chr.Replace("&gt;", ">");
            chr = chr.Replace("<br>", "\n");
            chr = chr.Replace("&nbsp;&nbsp;&nbsp;", "\t");
            chr = chr.Replace("'","'");
            return chr;
        }
        protected string Output(object inputString)
        {
            if (inputString == null)
                return string.Empty;

            StringBuilder strBuilder = new StringBuilder();
            string str1 = HttpContext.Current.Server.HtmlEncode(inputString.ToString());
            strBuilder.Insert(0, str1);
            strBuilder.Replace(((char)32).ToString(), "&nbsp;");
            strBuilder.Replace(((char)9).ToString(), "&nbsp;");
            strBuilder.Replace(((char)34).ToString(), "&quot;");
            strBuilder.Replace(((char)39).ToString(), "'");
            strBuilder.Replace(((char)13).ToString(), " ");
            strBuilder.Replace(((char)10).ToString() + ((char)10).ToString(), "</P><P>");
            strBuilder.Replace(((char)10).ToString(), "<BR>");

            return strBuilder.ToString();
        } 
     
 }
}

posted on 2007-12-10 13:03 top15from_old1 阅读(...) 评论(...) 编辑 收藏

导航

公告

随州简爱保罗定制衣柜专卖店为您准备了全套家装所需的定制家具,用工厂直销的价格和衣柜行业领导品牌的实力恭候您的光临。 随州市清河路清河丽景大门右侧18307228966 0722-3594778