convert to decimal

• 06-21-2011, 11:55 AM
rjagan
convert to decimal
Hi friends,

i have a set of ascii data's i.e.,(cp437) format.. i want to convert these ascii values to decimal..
is this possible to convert.

String asciicp437 = "ÑΩ∞ód~" // (cp437 or IBM437)

am tried the normal concept but i didn't work..

here is my code
String asciicp437 = "ÑΩ∞ód~╣µÜ<";
for(..........)
{

char ch = asciicp437.charAt(i);
int a = (int)(ch);
String hex = Integer.toHexString(a);
system.out.println(hex);
}

any one can solve this

thanks and regards
jagan R
• 06-21-2011, 11:58 AM
Dark
When you put your code in [code][/code] tags it's easier to read.

Also, use a Short, Self Contained, Correct Example so we can see what's actually going on with your code.
• 06-21-2011, 12:11 PM
JosAH
Quote:

Originally Posted by rjagan
String hex = Integer.toHexString(a);

Please make up your mind: your topic title mentions a decimal representation of a char while your code converts an int to a hexadecimal representation; what do you want?

kind regards,

Jos
• 06-21-2011, 12:15 PM
rjagan
that's not a problem.. dec == hex == ascii == binary all are have the equvalant value.. i need any one of the conversion..

do u have the solution for this.. ??
• 06-21-2011, 12:19 PM
JosAH
Quote:

Originally Posted by rjagan
that's not a problem.. dec == hex == ascii == binary all are have the equvalant value.. i need any one of the conversion..

do u have the solution for this.. ??

Maybe, but what "doesn't work" with your code? You have to be explicit about (the behaviour of) your code.

kind regards,

Jos
• 06-21-2011, 12:23 PM
rjagan
my code working finely.. but it converts the ascii value (cp437) to dec it shows the decimal value from cp1252 format (windows format)

i have the codepage437 ascii value.. to convert decimal
• 06-21-2011, 01:34 PM
Norm
Quote:

String asciicp437 = "ÑΩ∞ód~╣µÜ<";
What value, in what data type, do you expect to receive when you convert this?