Escape the escapes (") and (\\) with escapes.  These characters will be replaced with
(&quot) and (\\\\) respectively.
@param value the string to escape
@return the escaped string
186847
public static String escapeEscapes(String value)
    {
        assert(value != null);
        InternalStringBuilder sb = new InternalStringBuilder(value.length());
        for (int i = 0; i < value.length(); i++) {
            char c = value.charAt(i);
            if (c == '"') {
                sb.append("&quot;");
                continue;
            }
            if (c == '\\') {
                sb.append("\\\\");
                continue;
            }
            sb.append(c);
        }
        return sb.toString();
    }
979071
public static String escape(String v) {
        if (v==null)    return null;

        StringBuilder buf = new StringBuilder(v.length()+64);
        for( int i=0; i<v.length(); i++ ) {
            char ch = v.charAt(i);
            if(ch=='<')
                buf.append("&lt;");
            else
            if(ch=='>')
                buf.append("&gt;");
            else
            if(ch=='&')
                buf.append("&amp;");
            else
                buf.append(ch);
        }
        if (buf.length()==v.length())   return  v;  // unmodified
        return buf.toString();
    }
438429
public static String escapeString(String input) {
        StringBuilder escaped = new StringBuilder(input.length() + 10);
        escaped.append('"');
        for (int i = 0; i < input.length(); i++) {
            if (input.charAt(i) == '"') {
                escaped.append("\"\"");
            } else {
                escaped.append(input.charAt(i));
            }
        }
        escaped.append('"');
        return escaped.toString();
    }
564033
function escape (string) {
  return string
    .replace(/ /g, '\\ ')
    .replace(/\n/g, '')
    .replace(/\(/g, '\\(')
    .replace(/\)/g, '\\)');
}
3082
public static String escape(String literal)
    {
        StringBuilder sb = new StringBuilder();
        for (int ii = 0; ii < literal.length(); ii++)
        {
            char cc = literal.charAt(ii);
            switch (cc)
            {
                case '[':
                case ']':
                case '(':
                case ')':
                case '\\':
                case '-':
                case '^':
                case '*':
                case '+':
                case '?':
                case '|':
                case '.':
                case '{':
                case '}':
                case '&':
                case '$':
                case ',':
                    sb.append("\\").append(cc);
                    break;
                default:
                    sb.append(cc);
                    break;
            }
        }
        return sb.toString();
    }
1185651
public static String escape(CharSequence string) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < string.length(); ++i) {
            char c = string.charAt(i);
            switch (c) {
                case '\b':
                    builder.append('\\').append('b');
                    break;
                case '\t':
                    builder.append('\\').append('t');
                    break;
                case '\n':
                    builder.append('\\').append('n');
                    break;
                case '\f':
                    builder.append('\\').append('f');
                    break;
                case '\r':
                    builder.append('\\').append('r');
                    break;
                case '"':
                case '\'':
                    builder.append('\\').append(c);
                    break;
                case '\\':
                    builder.append('\\').append('\\');
                    break;
                default:
                    if (c < 32 || c == 127) {
                        builder.append(String.format("\\%03o", (int) c));
                    } else if (!isConsolePrintable(c) ||
                               Character.isHighSurrogate(c) ||
                               Character.isLowSurrogate(c)) {
                        builder.append(String.format("\\u%04x", (int) c));
                    } else {
                        builder.append(c);
                    }
                    break;
            }
        }
        return builder.toString();
    }
972396
static String escapeControlSymbols(String value) {
    if (value == null || value.isEmpty()) {
      return value;
    }
    StringBuilder result = null;
    for (int i = 0; i < value.length(); i++) {
      char ch = value.charAt(i);
      if (Character.getType(ch) == Character.CONTROL) {
        if (result == null) {
          result = new StringBuilder();
          if (i != 0) {
            result.append(value, 0, i);
          }
        }
        result.append(ESCAPING_MAP.get(ch));
      } else if (result != null) {
        result.append(ch);
      }
    }
    return result == null ? value : result.toString();
  }
57371
public static String escape(String str) {
		if (StrUtil.isEmpty(str)) {
			return str;
		}

		final int len = str.length();
		final StringBuilder builder = new StringBuilder(len);
		char c;
		for (int i = 0; i < len; i++) {
			c = str.charAt(i);
			builder.append(escape(c));
		}
		return builder.toString();
	}
480911
public static String removeBackslashEscape(String value) {
        StringBuffer sb = new StringBuffer();
        int i, n = value.length();
        char ch;
        boolean lastIsEscape = false;
        for (i=0; i<n; i++) {
            ch = value.charAt(i);
            if (lastIsEscape) {
                sb.append(ch);
                lastIsEscape = false;
            } else {
                if (ch=='\\') lastIsEscape = true;
                else sb.append(ch);
            }
        }
        return sb.toString();
    }
205558
function escapeAttribute(value) {
    return value.replace(/&/g, '&amp;').replace(/'/g, '&apos;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
981908
public static String escapeString(String value, boolean noBackslashEscapes) {
    if (!value.contains("'")) {
      if (noBackslashEscapes) {
        return value;
      }
      if (!value.contains("\\")) {
        return value;
      }
    }
    String escaped = value.replace("'", "''");
    if (noBackslashEscapes) {
      return escaped;
    }
    return escaped.replace("\\", "\\\\");
  }
607725
def escape(value, quote=True):
    '''
    
    '''
    def escape_one(match):
        return SPECIAL_CHARS[match.group(0)]

    if isinstance(value, string_types):
        value = SPECIAL_CHARS_REGEX.sub(escape_one, value)
        if quote:
            value = "'" + value + "'"
    return text_type(value)
1266913
def escape_string(value):
    
    res = StringIO()
    res.write('"')
    for c in value:
        if c in CHAR_TO_ESCAPE:
            res.write(f'\\{CHAR_TO_ESCAPE[c]}')
        elif c.isprintable():
            res.write(c)
        elif ord(c) < 0x100:
            res.write(f'\\x{ord(c):02x}')
        elif ord(c) < 0x10000:
            res.write(f'\\u{ord(c):04x}')
        else:
            res.write(f'\\U{ord(c):06x}')
    res.write('"')
    return res.getvalue()
984474
public static String filterEncode(String value) {

        if (value == null)
            return null;

        // make buffer roomy
        StringBuilder encodedValue = new StringBuilder(value.length() * 2);

        int length = value.length();

        for (int i = 0; i < length; i++) {

            char c = value.charAt(i);

            if (c < FILTER_ESCAPE_TABLE.length) {
                encodedValue.append(FILTER_ESCAPE_TABLE[c]);
            } else {
                // default: add the char
                encodedValue.append(c);
            }
        }

        return encodedValue.toString();
    }
189492
private function escape($value)
    {
        if (1 !== preg_match($this->escapeCharacterPattern, $value)) {
            return htmlspecialchars($value, ENT_QUOTES);
        }

        return str_replace(
            $this->controlCharacters, $this->escapeCharacters, htmlspecialchars($value, ENT_QUOTES)
        );
    }
1031088
public static String encode(String value) {
        if (value == null) {
            return value;
        }
        try {
            value = URLEncoder.encode(value, Constants.UTF_8);
        } catch (UnsupportedEncodingException e) {
            // Do nothing - UTF-8 should always be supported
        }
        return value;
    }
1319217
protected String escape(final Object src) {

		final StringBuilder output = new StringBuilder();
		final String input         = src.toString();

		for (int i = 0; i < input.length(); i++) {

			final char c        = input.charAt(i);
			final String prefix = SPECIAL_CHARS.get(c);

			if (prefix != null) {
				output.append(prefix);
			}

			output.append(c);
		}

		return output.toString();
	}