Reputation: 2753
I'm not sure if this is a Java or a Font question, however, I'm using the java.awt.Font class.
I am using the java.awt.Font class to draw glyphs to the screen. There are functions that allow me to pass it a character to draw. There are functions that allow me to pass it a code point to draw.
What is the relation between (char ch) and (int codepoint) for characters that are a-z, A-Z, 0-9? Does some standard guarantee that for these alphanumeric characters, the code point value is just the char's ascii value?
Thanks!
Upvotes: 0
Views: 339
Reputation: 44808
A char
is a 16 bit Unicode character. One char
can represent any Unicode character between \u0000
to \uffff
, and all of those characters fall in that range. The reason there are methods that take char
and others that take code points is because Unicode actually allocates space for 1,114,112 characters, and char
, being a 16 bit primitive, can only represent the first 65,536 of those.
Upvotes: 1
Reputation: 6203
Codepoint is the new lingo equivalent to your old "ASCII value". Since modern encodings go way beyond ASCII's 7 bits, another word had to be coined. But most encodings have the same first 127 characters/codepoints as ASCII - so you're safe here, unless you're dealing with exotic IBM encodings ;-)
Upvotes: 2