Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

using codePointAt()

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

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?
 
Marshal
Posts: 74371
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you need to convert the UTF-8 charset languages into a Unicode standard format, use this method.

STRING.codePointAt(INDEX);

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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic