コード例 #1
0
  /**
   * Returns true if the specified key produces a glyph.
   *
   * @param keyCode The key code.
   * @return True if the key is a printing key.
   */
  public boolean isPrintingKey(int keyCode) {
    int type = Character.getType(nativeGetDisplayLabel(mPtr, keyCode));

    switch (type) {
      case Character.SPACE_SEPARATOR:
      case Character.LINE_SEPARATOR:
      case Character.PARAGRAPH_SEPARATOR:
      case Character.CONTROL:
      case Character.FORMAT:
        return false;
      default:
        return true;
    }
  }
コード例 #2
0
 public static boolean isPrintable(char c) {
   if (Character.isJavaIdentifierStart(c)) {
     // Letters and $ _
     return true;
   }
   if (Character.isDigit(c)) {
     return true;
   }
   switch (Character.getType(c)) {
     case Character.MODIFIER_SYMBOL:
       return true; // ` ^
     case Character.DASH_PUNCTUATION:
       return true; // -
     case Character.MATH_SYMBOL:
       return true; // = ~ + | < >
     case Character.OTHER_PUNCTUATION:
       return true; // !@#%&*;':",./?
     case Character.START_PUNCTUATION:
       return true; // ( [ {
     case Character.END_PUNCTUATION:
       return true; // ) ] }
   }
   return false;
 }