public static string DoubleQuoteString(string value) { if (!MySqlHelper.needsQuoting(value)) { return(value); } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < value.Length; i++) { char c = value[i]; MySqlHelper.CharClass charClass = MySqlHelper.charClassArray[(int)c]; if (charClass == MySqlHelper.CharClass.Quote) { stringBuilder.Append(c); } else { if (charClass == MySqlHelper.CharClass.Backslash) { stringBuilder.Append("\\"); } } stringBuilder.Append(c); } return(stringBuilder.ToString()); }
public static string EscapeString(string value) { if (!MySqlHelper.needsQuoting(value)) { return(value); } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < value.Length; i++) { char c = value[i]; if (MySqlHelper.charClassArray[(int)c] != MySqlHelper.CharClass.None) { stringBuilder.Append("\\"); } stringBuilder.Append(c); } return(stringBuilder.ToString()); }