Unicode value of a character  
Author Message
jpr105





PostPosted: 2004-4-25 21:13:00 Top

java-programmer, Unicode value of a character Hi,

I am a beginner in Java programming and I would like to know which
code ( program ) I must write to get the Unicode value of any
character ?

Thank you very much for your help !

JPR105.
 
Andrew Thompson





PostPosted: 2004-4-25 21:27:00 Top

java-programmer >> Unicode value of a character On 25 Apr 2004 06:12:40 -0700, JPR105 wrote:

> I am a beginner in Java programming

A much nicer group is this one..
<http://www.physci.org/codes/javafaq.jsp#cljh>

Some of the people here are
just horrible, I've heard. ;-)

>...and I would like to know which
> code ( program ) I must write to get the Unicode value of any
> character ?

_Any_ character? Here's three..
<http://www.physci.org/codes/char.jsp>
<http://www.physci.org/codes/char.jsp?char=174>
<http://www.physci.org/codes/char.jsp?char=937>

You can also trawl though the charset here..
<http://www.physci.org/codes/charset.jsp?frame=1>

HTH

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Chris Smith





PostPosted: 2004-4-25 21:53:00 Top

java-programmer >> Unicode value of a character JPR105 wrote:
> I am a beginner in Java programming and I would like to know which
> code ( program ) I must write to get the Unicode value of any
> character ?

I'm not entirely sure what you mean. I could probably be more helpful
if you could specify your input and output more precisely.

If you have the character in a Java 'char' data type, then it *is* the
Unicode value. If you'd like to get the Unicode value in a different
numeric data type, just assign it as such:

char c = 'A';
int unicodeVal = c;

or cast it, if you don't have an appropriate intermediate variable and
the promotion won't be done automatically:

doSomething((int) c);

If your input is in a different type, then it will depend on what that
type is. In general, though, this should be a trivial task.

NOTE: This gets a little more difficult if you want to deal with Unicode
3.0 and surrogates. If that's the situation, then please say so, and
someone will probably give you an answer. It won't be me, unless I have
the chance to learn more about surrogates between now and then.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation