codepoint : Java Glossary
home C words local find no local find frame, full screen Google search web for topic jump to footer translate with Babelfish by Roedy Green ©1996-2008 Canadian Mind Products
Go to : punctuation 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (all)
codepoint
Unicode started out as a 16-bit code with 64K possible characters. At first, this seemed more than enough to encode all the world’s alphabets. Unicode was such a success, scholars also soon wanted to encode dead scripts such as cuneiform as well, and soon all the slots were full.

Unicode was extended to 32 bits, with the corresponding UTF-16 encoding also extended with a clumsy system of surrogate characters to encode the 32-bit characters above 0xffff.

The term codepoint in Java tends to be used to mean a slot in the 32-bit Unicode assignment, though I suspect the term is also valid to mean a spot in Unicode-16 or any other character set.

Java now straddles the 16-bit and 32-bit worlds. You might think Java would now have a 32-bit analog to Character, perhaps called CodePoint, and a 32-bit analog to String, perhaps called CodePoints, but it does not. Instead, Strings and char[] are permitted to contain surrogate pairs which encode a single high-32-bit codepoint.

StringBuilder.appendCodePoint( int codepoint ) will accept 32-bit codepoints to append.

StringBuilder.append( int number ) just converts the number to a String and adds that, not what you want!

FontMetrics.charWidth( int codepoint ) will tell you the width in pixels to render a given codepoint.

Character.isValidCodePoint( int codepoint ) will tell you if there is a glyph assigned to that codepoint. That is still no guarantee your Font will render it though. Character. codePointAt and codePointBefore let you deal with 32-bit codepoints encoded as surrogate pairs in char arrays. Most of the Character methods now have a version that accepts an int codepoint such as toLowerCase.

Iterating Over A String


CMP_homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.18] The information on this page is for non-military use only.
You are visitor number 5,293. Military use includes use by defence contractors.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/Mindprod website mirror)
http://mindprod.com/jgloss/codepoint.html J:\mindprod\jgloss\codepoint.html