Character.getNumericValue() - Numeric Value of Code Point

This section provides tutorial example on how to test 'Character' class getNumericValue() static methods to obtain the numeric value associated with a given Unicode character.

One interecting static method offered in the "Character" class is the "getNumericValue(int codePoint)" method, which returns a numeric value represented by the given Unicode character.

Here is a tutorial example on how to use "getNumericValue()" and other related methods:

/**
 * UnicodeCharacterNumeric.java
 - Copyright (c) 2012, HerongYang.com, All Rights Reserved.
 */
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
class UnicodeCharacterNumeric {
   static int[] unicodeList = {0x37, 0x0667, 0x2166, 0x3286, 0x4E03, 
      0x1F108};
   public static void main(String[] arg) {
      try {   	
         for (int i=0; i<unicodeList.length; i++) {

// Starting with the code point value
            int codePoint  = unicodeList[i];

// Dumping data in HEX numbers
            System.out.print("\n");
            System.out.print("\n                 Code point: "
               +Integer.toHexString(codePoint).toUpperCase());

// Getting Unicode character numeric values
            System.out.print("\n                isDefined(): "
               +Character.isDefined(codePoint));
            System.out.print("\n                  getName(): "
               +Character.getName(codePoint));
            System.out.print("\n          getNumericValue(): "
               +Character.getNumericValue(codePoint));
               
// Getting Unicode character type
            int intType = Character.getType(codePoint);
            System.out.print("\n                  getType(): "
               +intType);
            System.out.print("\n    is DECIMAL_DIGIT_NUMBER: "
               +(intType==Character.DECIMAL_DIGIT_NUMBER));
            System.out.print("\n                  isDigit(): "
               +Character.isDigit(codePoint));
         }
      } catch (Exception e) {
         System.out.print("\n"+e.toString());
      }
   }
}

Compile and run it with Java Se 7:

C:\herong>javac UnicodeCharacterNumeric.java

C:\herong>java UnicodeCharacterNumeric

                 Code point: 37
                  getName(): DIGIT SEVEN
          getNumericValue(): 7
                  getType(): 9
    is DECIMAL_DIGIT_NUMBER: true
                  isDigit(): true

                 Code point: 667
                  getName(): ARABIC-INDIC DIGIT SEVEN
          getNumericValue(): 7
                  getType(): 9
    is DECIMAL_DIGIT_NUMBER: true
                  isDigit(): true

                 Code point: 2166
                  getName(): ROMAN NUMERAL SEVEN
          getNumericValue(): 7
                  getType(): 10
    is DECIMAL_DIGIT_NUMBER: false
                  isDigit(): false

                 Code point: 3286
                  getName(): CIRCLED IDEOGRAPH SEVEN
          getNumericValue(): 7
                  getType(): 11
    is DECIMAL_DIGIT_NUMBER: false
                  isDigit(): false

                 Code point: 4E03
                  getName(): CJK UNIFIED IDEOGRAPHS 4E03
          getNumericValue(): -1
                  getType(): 5
    is DECIMAL_DIGIT_NUMBER: false
                  isDigit(): false

                 Code point: 1F108
                  getName(): DIGIT SEVEN COMMA
          getNumericValue(): 7
                  getType(): 11
    is DECIMAL_DIGIT_NUMBER: false
                  isDigit(): false

Some interesting notes on the output:

Last update: 2012.

Table of Contents

 About This Book

 Character Sets and Encodings

 ASCII Character Set and Encoding

 GB2312 Character Set and Encoding

 GB18030 Character Set and Encoding

 JIS X0208 Character Set and Encodings

 Unicode Character Set

 UTF-8 (Unicode Transformation Format - 8-Bit)

 UTF-16, UTF-16BE and UTF-16LE Encodings

 UTF-32, UTF-32BE and UTF-32LE Encodings

Java Language and Unicode Characters

 Unicode Versions Supported in Java-History

 'int' and 'String' - Basic Data Types for Unicode

 "Character" Class with Unicode Utility Methods

 Character.toChars() - "char" Sequence of Code Point

Character.getNumericValue() - Numeric Value of Code Point

 "String" Class with Unicode Utility Methods

 String.length() Is Not Number of Characters

 String.toCharArray() Returns the UTF-16BE Sequence

 Character Encoding in Java

 Character Set Encoding Maps

 Encoding Conversion Programs for Encoded Text Files

 Using Notepad as a Unicode Text Editor

 Using Microsoft Word as a Unicode Text Editor

 Using Microsoft Excel as a Unicode Text Editor

 Unicode Fonts

 Unicode Code Point Blocks - Code Charts

 Outdated Tutorials

 References

 PDF Printing Version