文字格式转换(Text与Html)

ExpandedBlockStart.gif 代码
     public   string  writeStr( string  oldStr)
    {
        
// oldStr=oldStr.Replace("''","'");   
        oldStr  =  oldStr.Replace( "     " "   " );
        oldStr 
=  oldStr.Replace( " &lt; " " < " );
        oldStr 
=  oldStr.Replace( " &gt; " " > " );
        oldStr 
=  oldStr.Replace( " <br/> " " \n " );
        oldStr 
=  oldStr.Replace( " &nbsp;&nbsp;&nbsp; " " \t " );
        oldStr 
=  oldStr.Replace( " &quot; " " \ "" );
         return  oldStr;
    }
    
public   string  readStr( string  oldStr)
    {
        
// oldStr=oldStr.Replace("'","''");   
        oldStr  =  oldStr.Replace( " &nbsp; " "     " );
        oldStr 
=  oldStr.Replace( " < " " &lt; " );
        oldStr 
=  oldStr.Replace( " > " " &gt; " );
        oldStr 
=  oldStr.Replace( " \n " " <br/> " );
        oldStr 
=  oldStr.Replace( " \t " " &nbsp;&nbsp;&nbsp; " );
        oldStr 
=  oldStr.Replace( " \ "" " & quot; " );
         return  oldStr;
    }

 在提交文章的时候把换行符Convert.ToString((char)13)   +   Convert.ToString((char)10)替换成HTML代码</P>、<BR>什么的

转载于:https://www.cnblogs.com/qiangshu/archive/2010/05/07/1729422.html

猜你喜欢

转载自blog.csdn.net/weixin_33736048/article/details/94688212
今日推荐