// 把纯文本变为适合html显示的格式 public static string GetHtmlContentFromPureText( string strText, Text2HtmlStyle style) { string[] aLine = strText.Replace("\r", "").Split(new char[] { '\n' }); string strResult = ""; for (int i = 0; i < aLine.Length; i++) { string strLine = aLine[i]; if (style == Text2HtmlStyle.BR) { strResult += strLine + "<br/>"; } else if (style == Text2HtmlStyle.P) { if (String.IsNullOrEmpty(strLine) == true) { strResult += "<p> </p>"; } else { strResult += "<p>" + strLine + "</p>"; } } else { if (String.IsNullOrEmpty(strLine) == true) { strResult += "<p> </p>"; } else { strResult += "<p>" + strLine + "</p>"; } } } return(strResult); }
// 把纯文本变为适合html显示的格式 static string GetHtmlContentFromPureText( string strText, Text2HtmlStyle style) { string[] aLine = strText.Replace("\r", "").Split(new char[] { '\n' }); string strResult = ""; for (int i = 0; i < aLine.Length; i++) { string strLine = aLine[i]; if (style == Text2HtmlStyle.BR) { strResult += strLine + "<br/>"; } else if (style == Text2HtmlStyle.P) { if (String.IsNullOrEmpty(strLine) == true) strResult += "<p> </p>"; else { strResult += "<p>" + strLine + "</p>"; } } else { if (String.IsNullOrEmpty(strLine) == true) strResult += "<p> </p>"; else { strResult += "<p>" + strLine + "</p>"; } } } return strResult; }