public static string XMLText(string Text) { string str2 = ""; int num3 = Text.Length - 1; for (int i = 0; i <= num3; i++) { string str = Conversions.ToString(Text[i]); string str4 = str; if (str4 == "<") { str2 = str2 + "<"; } else if (str4 == ">") { str2 = str2 + ">"; } else if (str4 == "&") { str2 = str2 + "&"; } else if (str4 == "\"") { str2 = str2 + """; } else { int num = Strings.AscW(str); if ((num >= 0x20) & (num <= 0x7e)) { str2 = str2 + str; } else { str2 = str2 + "&#" + Conversions.ToString(num) + ";"; } } } return(str2); }
public static string CleanString(string Text, bool ReplaceSpaceChar = true) { long num2; bool flag2 = ReplaceSpaceChar; if (!flag2) { bool flag = false; for (num2 = 1L; !((num2 > Strings.Len(Text)) | flag); num2 += 1L) { if (Strings.Mid(Text, (int)num2, 1) != " ") { flag = true; } } if (!flag) { flag2 = true; } } string str4 = ""; long num3 = Strings.Len(Text); for (num2 = 1L; num2 <= num3; num2 += 1L) { string str3; string str = Strings.Mid(Text, (int)num2, 1); long num = Strings.AscW(str); long num4 = num; switch (num4) { case 9L: str3 = "{HT}"; break; case 10L: str3 = "{LF}"; break; case 11L: str3 = "{VT}"; break; case 12L: str3 = "{FF}"; break; case 13L: str3 = "{CR}"; break; case 0x20L: if (flag2) { str3 = "{Space}"; } else { str3 = " "; } break; default: if (num4 == 160L) { str3 = "{NBSP}"; } else if (num4 == 0x20acL) { str3 = "{Euro Sign}"; } else if (((num >= 0x20L) & (num <= 0x7eL)) | ((num >= 160L) & (num <= 0xffL))) { str3 = str; } else { str3 = "{#" + Conversions.ToString(num) + "}"; } break; } str4 = str4 + str3; } return(str4); }