发布网友 发布时间:2024-10-24 12:53
共1个回答
热心网友 时间:6分钟前
提供一点思路:
定义两个函数完成进行文字格式转换:
public string writeStr(string oldStr)
{
//oldStr=oldStr.Replace( " ' ' ", " ' ");
oldStr=oldStr.Replace( " ", " ");
oldStr=oldStr.Replace( "< ", " < ");
oldStr=oldStr.Replace( "> ", "> ");
oldStr=oldStr.Replace( " <br/> ", "\n ");
oldStr=oldStr.Replace( " ", "\t ");
oldStr=oldStr.Replace( "" ", "\ " ");
return oldStr;
}
public string readStr(string oldStr)
{
//oldStr=oldStr.Replace( " ' ", " ' ' ");
oldStr=oldStr.Replace( " ", " ");
oldStr=oldStr.Replace( " < ", "< ");
oldStr=oldStr.Replace( "> ", "> ");
oldStr=oldStr.Replace( "\n ", " <br/> ");
oldStr=oldStr.Replace( "\t ", " ");
oldStr=oldStr.Replace( "\ " ", "" ");
return oldStr;
}
在提交文章的时候把换行符Convert.ToString((char)13) + Convert.ToString((char)10)替换成HTML代码 </P> 、 <BR> 什么的