get the escape for a character
@param ch
@return
488713
public String getEscape(char ch) {
      if (ch == escapeCharacter)
        return escapeCharacter + "E" + escapeCharacter;
      else if (ch == fieldDelimiter)
        return escapeCharacter + "F" + escapeCharacter;
      else if (ch == componentDelimiter)
        return escapeCharacter + "S" + escapeCharacter;
      else if (ch == subComponentDelimiter)
        return escapeCharacter + "T" + escapeCharacter;
      else if (ch == repetitionDelimiter)
        return escapeCharacter + "R" + escapeCharacter;
      else
        return null;
      }
1084030
public static String encodeBackslash(char c) {
    if (isAlphanumeric(c) || c == ' ') return ("" + c);
    String hex = Integer.toHexString(c);
    while (hex.length() < 4)
      hex = "0" + hex;
    return ("\\u" + hex);
  }
1354149
public static char caseCanonicalize(char ch) {
    if (ch < 0x80) {  // Normal case.
      return ('A' <= ch && ch <= 'Z') ? (char) (ch | 32) : ch;
    }
    // Non-ASCII case.
    if (CASE_SENSITIVE.contains(ch)) {
      for (DeltaSet ds : CANON_DELTA_SETS) {
        if (ds.codeUnits.contains(ch)) {
          return (char) (ch - ds.delta);
        }
      }
    }
    return ch;
  }
709789
private static final String escape(String str) {
        if (str == null) {
            return null;
        }

        StringBuilder sb = new StringBuilder(str.length() * 2);
        int len = str.length();
        for (int i = 0; i < len; i++) {
            char c = str.charAt(i);
            switch (c) {
                case TOKEN_DELIM:
                case USER_DATA_DELIM:
                case USER_ATTRIB_DELIM:
                    sb.append('\\');
                    break;
                default:
                    break;
            }
            sb.append(c);
        }
        return sb.toString();
    }
1307671
public static String escape(CharSequence s) {
		StringBuilder str = new StringBuilder();
		int len = s.length();
		for (int i = 0; i < len; ++i) {
			char c = s.charAt(i);
			if (c == '&') str.append("&amp;");
			else if (c == '"') str.append("&quot;");
			else if (c == '\'') str.append("&apos;");
			else if (c == '>') str.append("&gt;");
			else if (c == '<') str.append("&lt;");
			else if (c < 32) str.append("&#").append((int)c).append(';');
			else str.append(c);
		}
		return str.toString();
	}
125434
def _escape(self, s):
        
        for ch, r_ch in self.ESCAPE_SETS:
            s = s.replace(ch, r_ch)
        return s
685114
public void characters(char[] ch, int start, int length) {

        if (ignore)
            return;

        String content = new String(ch, start, length);
        // System.err.println("'" + content + "'");

        if (content.trim().length() == 0 && content.indexOf(' ') < 0) {
            return;
        }

        StringBuffer buf = new StringBuffer();
        int len = content.length();
        char character;
        boolean newline = false;
        for (int i = 0; i < len; i++) {
            switch (character = content.charAt(i)) {
            case ' ':
                if (!newline) {
                    buf.append(character);
                }
                break;
            case '\n':
                if (i > 0) {
                    newline = true;
                    buf.append(' ');
                }
                break;
            case '\r':
                break;
            case '\t':
                break;
            default:
                newline = false;
                buf.append(character);
            }
        }
        if (currentChunk == null) {
        	if (bf == null) {
        		currentChunk = new Chunk(buf.toString());
        	}
        	else {
        		currentChunk = new Chunk(buf.toString(), new Font(this.bf));
        	}
        } else {
            currentChunk.append(buf.toString());
        }
    }
377827
public static char getFirstLetter(char ch) {
		if (ch >= 'a' && ch <= 'z') {
			return ch;
		}
		if (ch >= 'A' && ch <= 'Z') {
			return Character.toLowerCase(ch);
		}
		final byte[] bys = String.valueOf(ch).getBytes(CharsetUtil.CHARSET_GBK);
		if (bys.length == 1) {
			return ch;
		}
		int count = (bys[0] + 256) * 256 + bys[1] + 256;
		if (count < 45217) {
			return ch;
		} else if (count < 45253) {
			return 'a';
		} else if (count < 45761) {
			return 'b';
		} else if (count < 46318) {
			return 'c';
		} else if (count < 46826) {
			return 'd';
		} else if (count < 47010) {
			return 'e';
		} else if (count < 47297) {
			return 'f';
		} else if (count < 47614) {
			return 'g';
		} else if (count < 48119) {
			return 'h';
		} else if (count < 49062) {
			return 'j';
		} else if (count < 49324) {
			return 'k';
		} else if (count < 49896) {
			return 'l';
		} else if (count < 50371) {
			return 'm';
		} else if (count < 50614) {
			return 'n';
		} else if (count < 50622) {
			return 'o';
		} else if (count < 50906) {
			return 'p';
		} else if (count < 51387) {
			return 'q';
		} else if (count < 51446) {
			return 'r';
		} else if (count < 52218) {
			return 's';
		} else if (count < 52698) {
			return 't';
		} else if (count < 52980) {
			return 'w';
		} else if (count < 53689) {
			return 'x';
		} else if (count < 54481) {
			return 'y';
		} else if (count < 55290) {
			return 'z';
		}
		return ch;
	}
149992
public static String escape(String string) {
        if (isEmpty(string)) return "";
        StringBuilder sb = new StringBuilder();
        char[] chars = string.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (i == chars.length - 1 || chars[i] != '\r' || chars[i + 1] != '\n') {
                sb.append(escape(chars[i]));
            }
        }
        return sb.toString();
    }
1351793
private static String escape(String string) {
    return StringUtils.escapeString(string, StringUtils.ESCAPE_CHAR, 
                                    charsToEscape);
  }
1301035
private void _appendCharacterEscape(char ch, int escCode)
			throws IOException, JsonGenerationException
	{
		if (escCode >= 0) { // \\N (2 char)
			if ((_outputTail + 2) > _outputEnd) {
				_flushBuffer();
			}
			_outputBuffer[_outputTail++] = '\\';
			_outputBuffer[_outputTail++] = (char) escCode;
			return;
		}
		if (escCode != CharacterEscapes.ESCAPE_CUSTOM) { // std, \\uXXXX
			if ((_outputTail + 5) >= _outputEnd) {
				_flushBuffer();
			}
			int ptr = _outputTail;
			char[] buf = _outputBuffer;
			buf[ptr++] = '\\';
			buf[ptr++] = 'u';
			// We know it's a control char, so only the last 2 chars are non-0
			if (ch > 0xFF) { // beyond 8 bytes
				int hi = (ch >> 8) & 0xFF;
				buf[ptr++] = HEX_CHARS[hi >> 4];
				buf[ptr++] = HEX_CHARS[hi & 0xF];
				ch &= 0xFF;
			} else {
				buf[ptr++] = '0';
				buf[ptr++] = '0';
			}
			buf[ptr++] = HEX_CHARS[ch >> 4];
			buf[ptr++] = HEX_CHARS[ch & 0xF];
			_outputTail = ptr;
			return;
		}
		String escape;
		if (_currentEscape == null) {
			escape = _characterEscapes.getEscapeSequence(ch).getValue();
		} else {
			escape = _currentEscape.getValue();
			_currentEscape = null;
		}
		int len = escape.length();
		if ((_outputTail + len) > _outputEnd) {
			_flushBuffer();
			if (len > _outputEnd) { // very very long escape; unlikely but theoretically possible
				_writer.write(escape);
				return;
			}
		}
		escape.getChars(0, len, _outputBuffer, _outputTail);
		_outputTail += len;
	}
870875
public String getReleaseCommand (char ch)
    {
        KeyRecord krec = _charCommands.get(ch);
        return (krec == null) ? null : krec.releaseCommand;
    }
308462
private int countChars(final char ch)
    {
        int count = 0;
        for (int i = 0; i < this.value.length(); i++)
        {
            final char c = this.value.charAt(i);
            if (c == ' ')
            {
                continue;
            }
            if (c == ch)
            {
                count++;
                continue;
            }
            count = 0;
            break;
        }
        return count;
    }
921832
public static final String escape(String s) {
        StringBuilder buf = new StringBuilder();
        for (int i=0; i<s.length(); ) {
            int c = Character.codePointAt(s, i);
            i += UTF16.getCharCount(c);
            if (c >= ' ' && c <= 0x007F) {
                if (c == '\\') {
                    buf.append("\\\\"); // That is, "\\"
                } else {
                    buf.append((char)c);
                }
            } else {
                boolean four = c <= 0xFFFF;
                buf.append(four ? "\\u" : "\\U");
                buf.append(hex(c, four ? 4 : 8));
            }
        }
        return buf.toString();
    }
485829
public Character getChar(String name) {
        Object o = get(name);
        if (o instanceof Character) {
            return (Character)o;
        }

        if (o != null) {
            String string = o.toString();
            if (string != null && string.length() == 1) {
                return string.charAt(0);
            }
        }
        return null;
    }
136086
public static String escape(char c) {
        switch (c) {
            case '\b':
                return "\\b";
            case '\t':
                return "\\t";
            case '\n':
                return "\\n";
            case '\f':
                return "\\f";
            case '\r':
                return "\\r";
            case '"':
                return "\\\"";
            case '\'':
                return "\\'";
            case '\\':
                return "\\\\";
            default:
                if (c < 32 || c == 127) {
                    return String.format("\\%03o", (int) c);
                } else if (!isConsolePrintable(c) ||
                           isHighSurrogate(c) ||
                           isLowSurrogate(c)) {
                    return String.format("\\u%04x", (int) c);
                }
                return String.valueOf(c);
        }
    }
557049
private static String escape(char c) {
		switch (c) {
		case '\b':
			return "\\b";
		case '\t':
			return "\\t";
		case '\n':
			return "\\n";
		case '\f':
			return "\\f";
		case '\r':
			return "\\r";
		default:
			if (c < StrUtil.C_SPACE || //
					(c >= '\u0080' && c <= '\u00a0') || //
					(c >= '\u2000' && c <= '\u2010') || //
					(c >= '\u2028' && c <= '\u202F') || //
					(c >= '\u2066' && c <= '\u206F')//
			) {
				return HexUtil.toUnicodeHex(c);
			} else {
				return Character.toString(c);
			}
		}
	}