File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Using the unicode library

Jessica Benady

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

Joined: Jan 03, 2004
Posts: 6109

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

Joined: Oct 13, 2005
Posts: 46320
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:
subject: Using the unicode library
It's not a secret anymore!