public static String ConvertToHtml(string strVal, bool lineFeeds, string feedType, bool hyperLinks, string linkParams)
{
string final = strVal;
string section = String.Empty;
int checkTAGS = 0;
int checkAMP = 0;
Regex regex;
if(final.Length > 0)
{
if(hyperLinks) final = AutoHyperlinks(final, linkParams);
if(InStr(final, "<") >= 0)
{
regex = new Regex(@"<([^>]*)>", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);
MatchCollection theMatches = regex.Matches(final);
if(theMatches.Count > 0) checkTAGS = 1;
for (int index = 0; index < theMatches.Count; index++)
{
if(checkAMP == 0 && InStr(theMatches[index].ToString(), "&") >= 0) checkAMP = 1;
section = theMatches[index].ToString().Replace("&", "[[[pk:amp]]]");
section = section.Replace("<", "[[[pk:lt]]]");
section = section.Replace(">", "[[[pk:gt]]]");
final = final.Replace(theMatches[index].ToString(), section);
}
}
if(InStr(final, ">") >= 0) final = final.Replace(">", ">");
if(InStr(final, "<") >= 0) final = final.Replace("<", "<");
if(InStr(final, "&") >= 0)
{
checkAMP = 1;
regex = new Regex(@"&([A-Za-z0-9]*);", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);
MatchCollection theMatches = regex.Matches(final);
for (int index = 0; index < theMatches.Count; index++)
{
section = theMatches[index].ToString().Replace("&", "[[[pk:amp]]]");
final = final.Replace(theMatches[index].ToString(), section);
}
final = final.Replace("&", "&");
}
for(int x = 128; x < 256; x++)
{
if(InStr(final, Convert.ToString(Convert.ToChar(x))) >= 0)
{
final = final.Replace(Convert.ToString(Convert.ToChar(x)), "&#" + x.ToString() + ";");
}
}
if(checkAMP == 1) final = final.Replace("[[[pk:amp]]]", "&");
if(checkTAGS == 1)
{
final = final.Replace("[[[pk:lt]]]", "<");
final = final.Replace("[[[pk:gt]]]", ">");
}
if(lineFeeds)
{
final = ConvertLinefeeds(final, feedType);
}
}
return(final);
}