aspose file tools
The moose likes Beginning Java and the fly likes using codePointAt() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using codePointAt()" Watch "using codePointAt()" New topic

using codePointAt()

Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45

I do not understand how to make use of codePointAt() method. Can anybody help me to understand with a simple code how and where we can make use of this method instead of using charAt() method?

Ken Sampson
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41599
Find a copy of Horstmann and Cornell (Core Java 2, Santa Clara: Sun Microsystems Press/Prentice-Hall). I have the 7th Edition (2005) and you find this on page 51, volume I.
If you
go to Unicode, you find that European and
African languages and numbers and symbols fill up much of the range between
0 and 65535 (0xFFFF), but there are gaps, some of several hundred numbers.
These gaps were used as supplementary symbols, as the first half of a
character from Chinese, etc., or even the big-Z which means "all integers."
These won't fit into the 16 bits of a char, so the 1st half goes in
one char and the 2nd half in the next char. There are methods
in the Character class which deal with this sort of thing. By putting the
two halves together, you get an int, which has space in 32 bits to
hold all conceivable Earthling languages, and probably Klingon as well.

So rather than Unicode having space for 65000 characters it now has space
for 1.1 million (or 17 million; I can't remember which). But if you stick to
European languages you will probably never need to worry about code points.

[ May 04, 2008: Message edited by: Campbell Ritchie to improve formatting: hence the code tabs]
[ May 04, 2008: Message edited by: Campbell Ritchie ]
dwarakanathan thiru
Ranch Hand

Joined: Oct 14, 2009
Posts: 49
If you need to convert the UTF-8 charset languages into a Unicode standard format, use this method.


The above will return the code point for the character you have keyed into the string.
Later you can paste it in browser and it is automatically decoded and displayed.

Try some chinese languages.

Dwarak T
Have you tried LearnNowOnline?
subject: using codePointAt()