Results 1 to 7 of 7
  1. #1
    rjagan's Avatar
    rjagan is offline Member
    Join Date
    Feb 2011
    Location
    Puducherry
    Posts
    53
    Rep Power
    0

    Post 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

  2. #2
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    5

    Default

    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.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,048
    Blog Entries
    7
    Rep Power
    23

    Default

    Quote Originally Posted by rjagan View Post
    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
    The only person who got everything done by Friday was Robinson Crusoe.

  4. #4
    rjagan's Avatar
    rjagan is offline Member
    Join Date
    Feb 2011
    Location
    Puducherry
    Posts
    53
    Rep Power
    0

    Default

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

  5. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,048
    Blog Entries
    7
    Rep Power
    23

    Default

    Quote Originally Posted by rjagan View Post
    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
    The only person who got everything done by Friday was Robinson Crusoe.

  6. #6
    rjagan's Avatar
    rjagan is offline Member
    Join Date
    Feb 2011
    Location
    Puducherry
    Posts
    53
    Rep Power
    0

    Default

    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

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    18,335
    Rep Power
    27

    Default

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

Similar Threads

  1. Convert Decimal To Binary
    By aspire007 in forum New To Java
    Replies: 8
    Last Post: 08-06-2010, 07:32 AM
  2. Replies: 4
    Last Post: 10-26-2009, 11:17 PM
  3. Convert binary into decimal
    By WarmRegards in forum New To Java
    Replies: 8
    Last Post: 10-18-2009, 02:32 PM
  4. Convert decimal to binary..pls help..newbie here
    By mephisto772 in forum New To Java
    Replies: 5
    Last Post: 02-12-2009, 09:17 AM
  5. Replies: 7
    Last Post: 01-12-2008, 10:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •