File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ASCII - UNICODE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ASCII - UNICODE" Watch "ASCII - UNICODE" New topic


Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

public static int getNumericValue(char ch)
Returns the int value that the specified Unicode character represents

Question: Isn't the first 128 characters of the unicode set are the same as the 128 chararcters of the 7-bit ASCII character set. Why am I getting different results.

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Joe Sondow
Ranch Hand

Joined: Apr 10, 2005
Posts: 195
Perhaps you're confused about the purpose of the Character.getNumericValue(char c) method. You can read about it here. From that page:

The letters A-Z in their uppercase ('\u0041' through '\u005A'), lowercase ('\u0061' through '\u007A'), and full width variant ('\uFF21' through '\uFF3A' and '\uFF41' through '\uFF5A') forms have numeric values from 10 through 35. This is independent of the Unicode specification, which does not assign numeric values to these char values.

So the numeric value returned from that method for the character 'a' should be 10. That doesn't mean the Unicode value. It means the numeric equivalent of the character, which doesn't make sense for a letter, so the method returns an arbitrary range of numbers for the letters.

Try this variation of your program to see one intended purpose of the getNumericValue method:

51 , 3

SCJA 1.0 (98%), SCJP 1.4 (98%)
Neelima Chandran

Joined: Jul 12, 2005
Posts: 12
Do we need to know the ranges of the unicode values for SCJP 1.4?

- Neelima
I agree. Here's the link:
subject: ASCII - UNICODE
It's not a secret anymore!