Example usage for java.lang Character isUnicodeIdentifierStart

List of usage examples for java.lang Character isUnicodeIdentifierStart

Introduction

In this page you can find the example usage for java.lang Character isUnicodeIdentifierStart.

Prototype

public static boolean isUnicodeIdentifierStart(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is permissible as the first character in a Unicode identifier.

Usage

From source file:Main.java

public static void main(String[] args) {
    char ch1 = '_', ch2 = 'p';
    boolean b1 = Character.isUnicodeIdentifierStart(ch1);
    boolean b2 = Character.isUnicodeIdentifierStart(ch2);

    System.out.println(b1);/* ww w . j  av a 2  s . c  om*/
    System.out.println(b2);
}

From source file:Main.java

public static void main(String[] args) {
    int cp1 = 0x037e; // represents GREEK QUESTION MARK
    int cp2 = 0x05d1; // represents HEBREW LETTER BET

    boolean b1 = Character.isUnicodeIdentifierStart(cp1);
    boolean b2 = Character.isUnicodeIdentifierStart(cp2);

    System.out.println(b1);//  ww  w.  j  av  a  2  s  .c  o m
    System.out.println(b2);
}

From source file:Main.java

public static void main(String[] args) throws java.io.IOException {
    char c = 'a';

    System.out.println("Character = " + (int) c);
    System.out.println("Defined = " + Character.isDefined(c));
    System.out.println("Digit = " + Character.isDigit(c));
    System.out.println("Ignorable = " + Character.isIdentifierIgnorable(c));
    System.out.println("ISO control = " + Character.isISOControl(c));
    System.out.println("Java identifier part = " + Character.isJavaIdentifierPart(c));
    System.out.println("Java identifier start = " + Character.isJavaIdentifierStart(c));
    System.out.println("Letter = " + Character.isLetter(c));
    System.out.println("Letter or digit = " + Character.isLetterOrDigit(c));
    System.out.println("Lowercase = " + Character.isLowerCase(c));
    System.out.println("Space = " + Character.isSpaceChar(c));
    System.out.println("Titlecase = " + Character.isTitleCase(c));
    System.out.println("Unicode identifier part = " + Character.isUnicodeIdentifierPart(c));
    System.out.println("Unicode identifier start = " + Character.isUnicodeIdentifierStart(c));
    System.out.println("Uppercase = " + Character.isUpperCase(c));
    System.out.println("White space = " + Character.isWhitespace(c));

    byte[] types = { Character.COMBINING_SPACING_MARK, Character.CONNECTOR_PUNCTUATION, Character.CONTROL,
            Character.CURRENCY_SYMBOL, Character.DASH_PUNCTUATION, Character.DECIMAL_DIGIT_NUMBER,
            Character.ENCLOSING_MARK, Character.END_PUNCTUATION, Character.FORMAT, Character.LETTER_NUMBER,
            Character.LINE_SEPARATOR, Character.LOWERCASE_LETTER, Character.MATH_SYMBOL,
            Character.MODIFIER_SYMBOL, Character.NON_SPACING_MARK, Character.OTHER_LETTER,
            Character.OTHER_NUMBER, Character.OTHER_PUNCTUATION, Character.OTHER_SYMBOL,
            Character.PARAGRAPH_SEPARATOR, Character.PRIVATE_USE, Character.SPACE_SEPARATOR,
            Character.START_PUNCTUATION, Character.SURROGATE, Character.TITLECASE_LETTER, Character.UNASSIGNED,
            Character.UPPERCASE_LETTER };

    String[] typeNames = { "Combining spacing mark", "Connector punctuation", "Control", "Currency symbol",
            "Dash punctuation", "Decimal digit number", "Enclosing mark", "End punctuation", "Format",
            "Letter number", "Line separator", "Lowercase letter", "Math symbol", "Modifier symbol",
            "Non spacing mark", "Other letter", "Other number", "Other punctuation", "Other symbol",
            "Paragraph separator", "Private use", "Space separator", "Start punctuation", "Surrogate",
            "Titlecase letter", "Unassigned", "Uppercase letter" };

    int type = Character.getType(c);

    for (int i = 0; i < types.length; i++)
        if (type == types[i]) {
            System.out.println("Type name = " + typeNames[i]);
            break;
        }//from w  w w  .  j a  va 2 s.  co  m

    System.out.println("Unicode block = " + Character.UnicodeBlock.of(c));
}

From source file:Classify.java

public static void main(String[] args) throws java.io.IOException {
    char c = '\u0beb'; // Tamil digit.

    System.out.println("Character = " + (int) c);
    System.out.println("Defined = " + Character.isDefined(c));
    System.out.println("Digit = " + Character.isDigit(c));
    System.out.println("Ignorable = " + Character.isIdentifierIgnorable(c));
    System.out.println("ISO control = " + Character.isISOControl(c));
    System.out.println("Java identifier part = " + Character.isJavaIdentifierPart(c));
    System.out.println("Java identifier start = " + Character.isJavaIdentifierStart(c));
    System.out.println("Letter = " + Character.isLetter(c));
    System.out.println("Letter or digit = " + Character.isLetterOrDigit(c));
    System.out.println("Lowercase = " + Character.isLowerCase(c));
    System.out.println("Space = " + Character.isSpaceChar(c));
    System.out.println("Titlecase = " + Character.isTitleCase(c));
    System.out.println("Unicode identifier part = " + Character.isUnicodeIdentifierPart(c));
    System.out.println("Unicode identifier start = " + Character.isUnicodeIdentifierStart(c));
    System.out.println("Uppercase = " + Character.isUpperCase(c));
    System.out.println("White space = " + Character.isWhitespace(c));

    byte[] types = { Character.COMBINING_SPACING_MARK, Character.CONNECTOR_PUNCTUATION, Character.CONTROL,
            Character.CURRENCY_SYMBOL, Character.DASH_PUNCTUATION, Character.DECIMAL_DIGIT_NUMBER,
            Character.ENCLOSING_MARK, Character.END_PUNCTUATION, Character.FORMAT, Character.LETTER_NUMBER,
            Character.LINE_SEPARATOR, Character.LOWERCASE_LETTER, Character.MATH_SYMBOL,
            Character.MODIFIER_SYMBOL, Character.NON_SPACING_MARK, Character.OTHER_LETTER,
            Character.OTHER_NUMBER, Character.OTHER_PUNCTUATION, Character.OTHER_SYMBOL,
            Character.PARAGRAPH_SEPARATOR, Character.PRIVATE_USE, Character.SPACE_SEPARATOR,
            Character.START_PUNCTUATION, Character.SURROGATE, Character.TITLECASE_LETTER, Character.UNASSIGNED,
            Character.UPPERCASE_LETTER };

    String[] typeNames = { "Combining spacing mark", "Connector punctuation", "Control", "Currency symbol",
            "Dash punctuation", "Decimal digit number", "Enclosing mark", "End punctuation", "Format",
            "Letter number", "Line separator", "Lowercase letter", "Math symbol", "Modifier symbol",
            "Non spacing mark", "Other letter", "Other number", "Other punctuation", "Other symbol",
            "Paragraph separator", "Private use", "Space separator", "Start punctuation", "Surrogate",
            "Titlecase letter", "Unassigned", "Uppercase letter" };

    int type = Character.getType(c);

    for (int i = 0; i < types.length; i++)
        if (type == types[i]) {
            System.out.println("Type name = " + typeNames[i]);
            break;
        }// ww  w .  j a v a2s. co  m

    System.out.println("Unicode block = " + Character.UnicodeBlock.of(c));
}

From source file:com.sun.socialsite.util.Utilities.java

/**
 * @param tag//from  w w  w  .j  a  v  a  2s .  c o  m
 * @return
 */
public static String stripInvalidTagCharacters(String tag) {
    if (tag == null)
        throw new NullPointerException();

    StringBuffer sb = new StringBuffer();
    char[] charArray = tag.toCharArray();
    for (int i = 0; i < charArray.length; i++) {
        char c = charArray[i];

        // fast-path exclusions quotes and commas are obvious
        switch (c) {
        case 34: // "
        case 44: // ,
            continue;
        }

        if ((33 <= c && c <= 126) || Character.isUnicodeIdentifierPart(c)
                || Character.isUnicodeIdentifierStart(c)) {
            sb.append(charArray[i]);
        }
    }
    return sb.toString();
}

From source file:org.tightblog.util.Utilities.java

/**
 * Removes non-alphanumerics from tags./*from   ww  w.  jav  a 2 s  .  co m*/
 *
 * @param tag tag to strip invalid chars from
 * @param locale to determine lower-case, default if null
 * @return lower case tag with alphanumerics removed
 */
public static String normalizeTag(String tag, Locale locale) {
    if (tag == null) {
        throw new NullPointerException();
    }

    StringBuilder sb = new StringBuilder();
    char[] charArray = tag.toCharArray();
    for (char c : charArray) {

        // fast-path exclusions quotes and commas are obvious
        // percent sign and forward slashes problematic in URLs and frequently blocked by servers
        // 34 = ", 37 = %, 39 = ', 44 = comma, 47 = /
        if (c == 34 || c == 37 || c == 39 || c == 44 || c == 47) {
            continue;
        }

        if ((33 <= c && c <= 126) || Character.isUnicodeIdentifierPart(c)
                || Character.isUnicodeIdentifierStart(c)) {
            sb.append(c);
        }
    }
    tag = sb.toString();
    return locale == null ? tag.toLowerCase() : tag.toLowerCase(locale);
}