Saturday, June 8, 2013

Print all digit in Unicode using java.lang.Character

The java.lang.Character class wraps a value of the primitive type char in an object. An object of type Character contains a single field whose type is char.

In addition, this class provides several methods for determining a character's category (lowercase letter, digit, etc.) and for converting characters from uppercase to lowercase and vice versa.

Character information is based on the Unicode Standard, version 6.0.0.

Character.MAX_CODE_POINT is the maximum value of a Unicode code point, constant U+10FFFF.

Character.isDigit(int codePoint) method determines if the specified character (Unicode code point) is a digit.


It's a example to print all digit in Unicode:

Print all digit in Unicode
Print all digit in Unicode

package java_unicodecodepoint;

/**
 * @web http://java-buddy.blogspot.com/
 */
public class Java_UnicodeCodePoint {

    public static void main(String[] args) {
        System.out.println("http://java-buddy.blogspot.com/");
        int maxCodePoint = Character.MAX_CODE_POINT;
        System.out.printf("MAX_CODE_POINT = %x\n", maxCodePoint);
        
        //print all digital Unicode
        for(int i=0; i<=maxCodePoint; i++){
            if(Character.isDigit(i)){
                System.out.printf("Unicode: %x\t%c\tName:%s\n", 
                    i, i, Character.getName(i));
            }
        }
    }
}


No comments:

Post a Comment