<p>Escape HTML character to UTF-8 for given character.</p>
@param pChar character e.g. '''
@return String escaped
495373
public final String htmlEscape(final char pChar) {
    if (pChar == ' ') {
      return "%20";
    } else if (pChar == '!') {
      return "%21";
    } else if (pChar == '"') {
      return "%22";
    } else if (pChar == '#') {
      return "%23";
    } else if (pChar == '$') {
      return "%24";
    } else if (pChar == '%') {
      return "%25";
    } else if (pChar == '&') {
      return "%26";
    } else if (pChar == '\'') {
      return "%27";
    } else if (pChar == '(') {
      return "%28";
    } else if (pChar == ')') {
      return "%29";
    } else if (pChar == '*') {
      return "%2A";
    } else if (pChar == '+') {
      return "%2B";
    } else if (pChar == ',') {
      return "%2C";
    } else if (pChar == '-') {
      return "%2D";
    } else if (pChar == '.') {
      return "%2E";
    } else if (pChar == '/') {
      return "%2F";
    } else if (pChar == ':') {
      return "%3A";
    } else if (pChar == ';') {
      return "%3B";
    } else if (pChar == '<') {
      return "%3C";
    } else if (pChar == '=') {
      return "%3D";
    } else if (pChar == '>') {
      return "%3E";
    } else if (pChar == '?') {
      return "%3F";
    } else if (pChar == '@') {
      return "%40";
    } //TODO all chars
    return String.valueOf(pChar);
  }
1242976
public static String escapeSpecialCharacters(String columnName, String escapeChars, String character) {
    if (Strings.isNullOrEmpty(columnName)) {
      return null;
    }

    if (StringUtils.isEmpty(escapeChars)) {
      return columnName;
    }

    List<String> specialChars = Arrays.asList(escapeChars.split(","));
    for (String specialChar : specialChars) {
      columnName = columnName.replace(specialChar, character);
    }
    return columnName;
  }
716947
def _pct_escape_handler(err):
    '''
    
    '''
    chunk = err.object[err.start:err.end]
    replacements = _pct_encoded_replacements(chunk)
    return ("".join(replacements), err.end)
239495
private char getEscaped() {
    pos++;
    if (pos == length) {
      throw new IllegalStateException("Unexpected end of DN: " + dn);
    }

    switch (chars[pos]) {
      case '"':
      case '\\':
      case ',':
      case '=':
      case '+':
      case '<':
      case '>':
      case '#':
      case ';':
      case ' ':
      case '*':
      case '%':
      case '_':
        //FIXME: escaping is allowed only for leading or trailing space char
        return chars[pos];
      default:
        // RFC doesn't explicitly say that escaped hex pair is
        // interpreted as UTF-8 char. It only contains an example of such DN.
        return getUTF8();
    }
  }
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();
	}
1095837
private static String escape(String string) {
        StringBuilder sb = new StringBuilder((int) (string.length() * 1.1));
        for (int i = 0; i < string.length(); i++) {
            char c = string.charAt(i);
            switch (c) {
            case ',':
                sb.append("=2C");
                break;
            case '=':
                sb.append("=3D");
                break;
            default:
                sb.append(c);
                break;
            }
        }
        return sb.toString();
    }
828574
protected String escapeXmlSpecialCharacters(String url) {
		// https://stackoverflow.com/questions/1091945/what-characters-do-i-need-to-escape-in-xml-documents
		return url
				.replace("&", "&amp;") // must be escaped first!!!
				.replace("\"", "&quot;")
				.replace("'", "&apos;")
				.replace("<", "&lt;")
				.replace(">", "&gt;");
	}
564793
public static String escapeJavaString(String s)
  {
    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < s.length(); i++) {
      char ch = s.charAt(i);

      switch (ch) {
      case '\\':
        sb.append("\\\\");
        break;
      case '\n':
        sb.append("\\n");
        break;
      case '\r':
        sb.append("\\r");
        break;
      case '"':
        sb.append("\\\"");
        break;
      default:
        sb.append(ch);
      }
    }

    return sb.toString();
  }
1016872
private String escapeUnrecognizedCharacters(String s) {
    // TODO(yitingwang) Move this method to a suitable place
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); i++) {
      char c = s.charAt(i);
      switch (c) {
          // From the SingleEscapeCharacter grammar production.
        case '\b':
        case '\f':
        case '\n':
        case '\r':
        case '\t':
        case '\\':
        case '\"':
        case '\'':
        case '$':
        case '`':
        case '\u2028':
        case '\u2029':
          sb.append(c);
          break;
        default:
          if ((outputCharsetEncoder != null && outputCharsetEncoder.canEncode(c))
              || (c > 0x1f && c < 0x7f)) {
            // If we're given an outputCharsetEncoder, then check if the character can be
            // represented in this character set. If no charsetEncoder provided - pass straight
            // Latin characters through, and escape the rest. Doing the explicit character check is
            // measurably faster than using the CharsetEncoder.
            sb.append(c);
          } else {
            // Other characters can be misinterpreted by some JS parsers,
            // or perhaps mangled by proxies along the way,
            // so we play it safe and Unicode escape them.
            Util.appendHexJavaScriptRepresentation(sb, c);
          }
      }
    }
    return sb.toString();
  }
514525
private char readEscapedChar() throws IOException {
    int ch = getChar();
    switch (ch) {
      case '"' : return '"';
      case '\'' : return '\'';
      case '\\' : return '\\';
      case '/' : return '/';
      case 'n' : return '\n';
      case 'r' : return '\r';
      case 't' : return '\t';
      case 'f' : return '\f';
      case 'b' : return '\b';
      case 'u' :
        return (char)(
               (hexval(getChar()) << 12)
             | (hexval(getChar()) << 8)
             | (hexval(getChar()) << 4)
             | (hexval(getChar())));
    }
    if ( (flags & ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER) != 0 && ch != EOF) {
      return (char)ch;
    }
    throw err("Invalid character escape");
  }
387141
function (char) {
                var
                    escapeChar = this._escapeChar,
                    count;
                if (char === escapeChar) {
                    count = ++this._escapeCount;
                    if ("-" === escapeChar && 3 === count) {
                        this._output("&mdash;");
                        return this._parseContent;
                    }
                } else {
                    count = this._escapeCount + 1;
                    while (--count) {
                        this._output(escapeChar);
                    }
                    this._setParserState(this._parseContent);
                    return this._parseContent(char);
                }
            }
598082
public static String escape(String pArg, String pEscape, String pDelimiter) {
        return pArg.replaceAll(pEscape, pEscape + pEscape).replaceAll(pDelimiter, pEscape + pDelimiter);
    }
195138
function escapeCssUrlChar(ch) {
    return cssUrlChars[ch]
        || (cssUrlChars[ch] = (ch < '\x10' ? '%0' : '%')
            + ch.charCodeAt(0).toString(16));
  }
431604
private String escapeStringSpecialCharacters(String str)
    {
        if (logger.isLoggable(Level.FINER)) logger.exiting(className, "escapeStringSpecialCharacters(String)");

        if (str != null)
        {
            StringBuffer strBuf = new StringBuffer("");

            for (int i = 0; i < str.length(); i++)
            {
                char strChar = str.charAt(i);

                switch (strChar)
                {
                    case '"':
                        {
                            strBuf.append("\\\"");
                            break;
                        }
                    case '\t':
                        {
                            strBuf.append("\\t");
                            break;
                        }
                    case '\b':
                        {
                            strBuf.append("\\b");
                            break;
                        }
                    case '\\':
                        {
                            strBuf.append("\\\\");
                            break;
                        }
                    case '\f':
                        {
                            strBuf.append("\\f");
                            break;
                        }
                    case '\r':
                        {
                            strBuf.append("\\r");
                            break;
                        }
                    case '/':
                        {
                            strBuf.append("\\/");
                            break;
                        }
                    default:
                        {
                            if ((strChar >= 32) && (strChar <= 126) )
                            {
                                strBuf.append(strChar);
                            }
                            else if (strChar > 126)
                            {
                              if ((escapeNonAsciiChars)) 
                              {
                                  strBuf.append("\\u");
                                  StringBuffer sb = new StringBuffer(Integer.toHexString(strChar));
                                  while (sb.length() < 4)
                                  {
                                      sb.insert(0,'0');
                                  }
                                  strBuf.append(sb.toString());
                              }
                              else {
                                strBuf.append(strChar);
                              }
                            }
                            else 
                            {
                                strBuf.append("\\u");
                                StringBuffer sb = new StringBuffer(Integer.toHexString(strChar));
                                while (sb.length() < 4)
                                {
                                    sb.insert(0,'0');
                                }
                                strBuf.append(sb.toString());
                            }

                            break;
                        }
                }
            }
            str = strBuf.toString();
        }
        if (logger.isLoggable(Level.FINER)) logger.exiting(className, "escapeStringSpecialCharacters(String)");
        return str;
    }
859916
def escape_path(str)
      result = ""
      str.scan(%r{/([^/]*)}).each{|i|
        result << "/" << _escape(i[0], UNESCAPED_PCHAR)
      }
      return result
    end
613324
public static boolean containsIgnoreCase(String pString, int pChar) {
        return ((pString != null)
                && ((pString.indexOf(Character.toLowerCase((char) pChar)) >= 0)
                || (pString.indexOf(Character.toUpperCase((char) pChar)) >= 0)));

        // NOTE: I don't convert the  string to uppercase, but instead test
        // the string (potentially) two times, as this is more efficient for
        // long strings (in most cases).
    }
1155315
public static String escapeXML(final String s) {
        final char[] chars = s.toCharArray();
        return escapeXML(chars, 0, chars.length);
    }