Utility methods for ASCII character checking. : Encoding « I18N « Java






Utility methods for ASCII character checking.

   
/**
 * Utility methods for ASCII character checking.
 */
public class ASCIIUtil {

  /**
   * Checks whether the supplied character is a letter or number.
   */
  public static boolean isLetterOrNumber(int c) {
    return isLetter(c) || isNumber(c);
  }

  /**
   * Checks whether the supplied character is a letter.
   */
  public static boolean isLetter(int c) {
    return isUpperCaseLetter(c) || isLowerCaseLetter(c);
  }

  /**
   * Checks whether the supplied character is an upper-case letter.
   */
  public static boolean isUpperCaseLetter(int c) {
    return (c >= 65 && c <= 90); // A - Z
  }

  /**
   * Checks whether the supplied character is an lower-case letter.
   */
  public static boolean isLowerCaseLetter(int c) {
    return (c >= 97 && c <= 122);  // a - z
  }

  /**
   * Checks whether the supplied character is a number
   */
  public static boolean isNumber(int c) {
    return (c >= 48 && c <= 57); // 0 - 9
  }
}

   
    
    
  








Related examples in the same category

1.Convert Encoding
2.Utility class for working with character sets
3.Reader for UCS-2 and UCS-4 encodings. (i.e., encodings from ISO-10646-UCS-(2|4)).
4.Conversions between IANA encoding names and Java encoding names, and vice versa.
5.ASCII character handling functions
6.This class represents an encoding.
7.Provides information about encodings.
8.Codec for the Quoted-Printable section of http://www.ietf.org/rfc/rfc1521.txt (RFC 1521)
9.ISO 8859-8, ASCII plus Hebrew
10.TIS-620 does not have the non-breaking space or the C1 controls.
11.ISO-8859-1; a.k.a. Latin-1
12.ISO 8859-2, a.k.a. Latin-2
13.ISO 8859-3
14.ISO 8859-4, Latin plus the characters needed for Greenlandic, Icelandic, and Lappish.
15.ISO 8859-9 for Turkish.
16.ISO-8859-10, for Lithuanian, Estonian, Greenlandic, Icelandic, Inuit, Lappish, and other Northern European languages.
17.ISO-8859-13, for Latvian and other Baltic languages.
18.ISO-8859-14, for Gaelic, Welsh, and other Celtic languages.
19.ISO 8859-9 for Western Europe. Includes the Euro sign and several uncommon French letters
20.ISO 8859-16, Romanian
21.ASCII Writer
22.UCS Writer
23.Unicode Writer
24.Whether a character is or is not available in a particular encoding
25.ISO 8859-6, ASCII plus Arabic
26.ISO 8859-5, ASCII plus Cyrillic (Russian, Byelorussian, etc.)
27.ISO 8859-7, ASCII plus Greek
28.IANA to Java Mapping
29.Java to IANA Mapping
30.EncodingMap is a convenience class which handles conversions between IANA encoding names and Java encoding names, and vice versa.
31.Get file encoding