Converting special characters in Java and JavaScript

C

Crazy Monkey

Hi:

I need to convert special characters into its numerical values. I
found charCodeAt() function in JavaScript that does the trick. For
example

var testString = "èû";
testString.charCodeAt(0) will return 138
testString.charCodeAt(1) will return 150


I need something in Java that will do the same thing. So far the
closest thing I got is

char char1 = 'è';
int ci = (int) char1; gives me 232

char char1 = 'û';
int ci = (int) char1; gives me 251


As you see, the conversion does not match. The Java part is giving me
a HTML encoded representation. JavaScript charCodeAt() is doing
something else. I need Java to generate the same code as JavaScript.
Any hints.

Thanks.



Crazy Monkey
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top