• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ASCII - UNICODE

 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Note:
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.
 
Joe Sondow
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:



output:
51 , 3
 
Neelima Chandran
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do we need to know the ranges of the unicode values for SCJP 1.4?

- Neelima
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic