Java Reference
In-Depth Information
public static char
forDigit(int digit, int radix)
Returns the character value for the specified digit in the spe-
cified radix. If the digit is not valid in the radix, the character
'\u0000'
is returned. For example,
forDigit(10,16)
returns
'a'
while
forDigit(16,16)
returns
'\u0000'
.
There are three character cases in Unicode: upper, lower, and title.
Uppercase and lowercase are familiar to most people. Titlecase distin-
guishes characters that are made up of multiple components and are
written differently when used in titles, where the first letter in a word
first letter is the lowercase letter
lj(\u01C9
, a letter in the Extended Lat-
in character set that is used in writing Croatian digraphs). If the word
appeared in a book title, and you wanted the first letter of each word
to be in uppercase, the correct process would be to use
toTitleCase
on
the first letter of each word, giving you
"Ljepotica"
(using
Lj
, which is
\u01C8
). If you incorrectly used
toUpperCase
, you would get the erroneous
string
"LJepotica"
(using
LJ
, which is
\u01C7
).
[2]
"Ljepotica" is a Croatian diminutive of "beauty," often used as a term of endearment and admiration.
All case issues are handled as defined in Unicode. For example, in Geor-
gian, uppercase letters are considered archaic, and translation into up-
percase is usually avoided. Therefore,
toUpperCase
will not change lower-
case Georgian letters to their uppercase equivalents, although
toLower-
Case
will translate uppercase Georgian letters to lowercase. Because of
such complexities, you cannot assume that converting characters to
either lower or upper case and then comparing the results will give you
a proper case-ignoring comparison. However, the expression
Character.toUpperCase(Character.toLowerCase(ch));
leaves you with a character that you can compare with another similarly
constructed character to test for equality ignoring case distinctions. If
the two resulting characters are the same, then the original characters