/// <summary> /// Escapes the execute text. /// </summary> /// <param name="buffer">The buffer.</param> /// <param name="value">The value.</param> private static void InternalEscapeText(InternalEscapeTextKind kind, StringBuilder b, string value) { switch (kind) { case InternalEscapeTextKind.Text: foreach (char c in value) { int code = (int)c; switch (c) { case '\'': b.Append("''"); break; default: if ((code >= 32) && (code < 128)) { b.Append(c); } else { b.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, "\\u{0:X4}", code); } break; } } break; case InternalEscapeTextKind.ExecuteText: foreach (char c in value) { int code = (int)c; switch (c) { case '\'': b.Append("''"); break; default: if ((code >= 32) && (code < 128)) { b.Append(c); } else { b.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, "\\u{0:X4}", code); } break; } } break; case InternalEscapeTextKind.Object: foreach (char c in value) { int code = (int)c; switch (c) { case '[': b.Append(""); break; case ']': b.Append(""); break; default: b.Append(c); break; } } break; default: throw new InvalidOperationException(); } }
private static void InternalEscapeText(InternalEscapeTextKind kind, StringBuilder b, string value) { switch (kind) { case InternalEscapeTextKind.Text: foreach (char c in value) { int code = (int)c; switch (c) { case '\'': b.Append("''"); break; default: if ((code >= 32) && (code < 128)) b.Append(c); else b.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, "\\u{0:X4}", code); break; } } break; case InternalEscapeTextKind.ExecuteText: foreach (char c in value) { int code = (int)c; switch (c) { case '\'': b.Append("''"); break; default: if ((code >= 32) && (code < 128)) b.Append(c); else b.AppendFormat(CultureInfo.InvariantCulture.NumberFormat, "\\u{0:X4}", code); break; } } break; case InternalEscapeTextKind.Object: foreach (char c in value) { int code = (int)c; switch (c) { case '[': b.Append(""); break; case ']': b.Append(""); break; default: b.Append(c); break; } } break; default: throw new InvalidOperationException(); } }