aspose file tools*
The moose likes Beginning Java and the fly likes Using the unicode library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Using the unicode library" Watch "Using the unicode library" New topic
Author

Using the unicode library

Jessica Benady
Greenhorn

Joined: Oct 14, 2012
Posts: 8
how do you convert lower case c to uppercase C without an appendix for the unicode library?
my prof told me it would be something like 'c'-'0' but I don't understand how that results in 'C'

could someone explain?
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

I don't know what the "unicode library" is, but the String and Character classes have toUpperCase() methods that you can use.

As for the arithmetic your prof is talking about, every character has a corresponding number (actually is a number, just interpreted a special way), and you can do math on those numerical values. And the numbers go in the same order as the letters, and increase by one with eacn subsequent letter, which is convenient sometimes, but shouldn't be relied on in an OO context, or when we might have to deal with more than just A-Z and a-z.

So, for instance, since 'G' comes 3 positions after 'D', we get 'G' - 'D' == 3. 'D' is 68 and G is 71, but those specific values don't matter here.

So, given that we have numbers for 'A'..'Z' and numbers for 'a'..'z', and even without knowing anything about what those numbers are or where the lowercase ones are in relation to the uppercase ones, it's just simple arithmetic to turn any lowercase to its corresponding uppercase, or vice-versa. I'll leave you to work out that last bit for yourself.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
I shall make that easier by showing you a link to the first Unicode chart. Note Unicode use proper numbers (hexadecimal).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using the unicode library