Therefore, the following functions are required for conversion:
Copy codeThe Code is as follows:
/// <Summary>
/// Replace special characters in html
/// </Summary>
/// <Paramname = "theString"> the text to be replaced. </Param>
/// <Returns> the replaced text. </Returns>
Public static string HtmlEncode (string theString)
{
TheString = theString. Replace (">", "> ");
TheString = theString. Replace ("<", "<");
TheString = theString. Replace ("","");
TheString = theString. Replace ("\"",""");
TheString = theString. Replace ("\'","'");
TheString = theString. Replace ("\ n", "<br/> ");
Return theString;
}
/// <Summary>
/// Restore special characters in html
/// </Summary>
/// <Paramname = "theString"> the text to be restored. </Param>
/// <Returns> restored text. </Returns>
Public static string HtmlDiscode (string theString)
{
TheString = theString. Replace (">", "> ");
TheString = theString. Replace ("<", "<");
TheString = theString. Replace ("","");
TheString = theString. Replace (""","\"");
TheString = theString. Replace ("'","\'");
TheString = theString. Replace ("<br/>", "\ n ");
Return theString;
}