• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ASCII - UNICODE

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do we need to know the ranges of the unicode values for SCJP 1.4?

- Neelima
 
reply
    Bookmark Topic Watch Topic
  • New Topic