Copy to ClipboardReference: [www.bkjia.com] public string EnCode (string content)
{
String str1 = content. Replace ("<", "<");
String str2 = str1.Replace (">", "> ");
String str3 = str2.Replace ("'", "& apos ;");
String str4 = str3.Replace ("","");
String str5 = str4.Replace ("\ r \ n", "<br> ");
String str6 = str5.Replace ("\"",""");
String str7 = str6.Replace ("&","&");
Return str7;
}
Public string UnCode (string content)
{
String str1 = content. Replace ("&","&");
String str2 = str1.Replace (""","\"");
String str3 = str2.Replace ("<br>", "\ r \ n ");
String str4 = str3.Replace ("","");
String str5 = str4.Replace ("'", "& apos ;");
String str6 = str5.Replace (">", "> ");
String str7 = str6.Replace ("<", "<");
Return str7;
This is used for SQL escape character conversion. At first, we found that only the first one was converted. At that time, I was depressed. In the dumbest way, I made two loops to replace the others. Later, you can change it to string str1 = content. Replace/& amp;/g, "&"); to Replace all.
Copy to ClipboardReference: [www.bkjia.com] public string EnCode (string content)
{
String str1 = content. replace (/</g, "<");
String str2 = str1.replace (/>/g, "> ");
}