Unicode value of a character

J

JPR105

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.
 
A

Andrew Thompson

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
 
C

Chris Smith

JPR105 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top