Converting Pack/Unpacked EBCDIC file to ASCII

Discussion in 'Java' started by kristenzhang@gmail.com, Feb 22, 2005.

  1. Guest

    Suppose I have a Pack/Unpacked EBCDIC file (.upd), what's the easist
    way to convert it to an ASCII file (.dat)? Do I need a conversion
    table and everything, or can I just do it with a simple Reader/Writer
    in Java and do it per byte?? Also, I will have a copybook file to help
    me convert & unpack. Please let me know if you have any suggestions!
    Thanks lots!
     
    , Feb 22, 2005
    #1
    1. Advertising

  2. Rhino Guest

    <> wrote in message
    news:...
    > Suppose I have a Pack/Unpacked EBCDIC file (.upd), what's the easist
    > way to convert it to an ASCII file (.dat)? Do I need a conversion
    > table and everything, or can I just do it with a simple Reader/Writer
    > in Java and do it per byte?? Also, I will have a copybook file to help
    > me convert & unpack. Please let me know if you have any suggestions!
    > Thanks lots!
    >

    This has been discussed many times in the past. A Google Newsgroups search
    should turn up the past discussions very quickly.

    Rhino
     
    Rhino, Feb 22, 2005
    #2
    1. Advertising

  3. Guest

    i've looked... and none was helpful...
     
    , Feb 22, 2005
    #3
  4. Guest

    at least not in Java...
     
    , Feb 22, 2005
    #4
  5. Rhino Guest

    <> wrote in message
    news:...
    > i've looked... and none was helpful...
    >


    Sorry, I just assumed that those old discussions would help you.

    I don't have anything to add to what they say.

    Rhino
     
    Rhino, Feb 22, 2005
    #5
  6. Alex Guest

    public static int EBCDIC(int i)
    {
    if(i >= 65 && i <= 73)
    return (i - 65) + 193;
    if(i >= 74 && i <= 82)
    return (i - 74) + 209;
    if(i >= 83 && i <= 90)
    return (i - 83) + 226;
    if(i >= 97 && i <= 105)
    return (i - 97) + 129;
    if(i >= 106 && i <= 114)
    return (i - 106) + 145;
    if(i >= 115 && i <= 122)
    return (i - 115) + 162;
    if(i >= 48 && i <= 57)
    return (i - 48) + 240;
    if(i == 32)
    return 64;
    return i != 0 ? 0 : 0;
    }

    That's by definition. But be careful. Very. Because each application
    has its own thoughts. For example, if you download text file via
    mainframe ftp and then upload it via UNIX ftp result is different. Some
    characters like | or ^Z are changed.
    Alex Kizub.
     
    Alex, Feb 22, 2005
    #6
  7. Eric Sosman Guest

    Alex wrote:
    > public static int EBCDIC(int i)
    > {
    > if(i >= 65 && i <= 73)
    > return (i - 65) + 193;
    > if(i >= 74 && i <= 82)
    > return (i - 74) + 209;
    > if(i >= 83 && i <= 90)
    > return (i - 83) + 226;
    > if(i >= 97 && i <= 105)
    > return (i - 97) + 129;
    > if(i >= 106 && i <= 114)
    > return (i - 106) + 145;
    > if(i >= 115 && i <= 122)
    > return (i - 115) + 162;
    > if(i >= 48 && i <= 57)
    > return (i - 48) + 240;
    > if(i == 32)
    > return 64;
    > return i != 0 ? 0 : 0;
    > }


    Observation #1: I think the O.P. wants to convert in
    the other direction.

    Observation #2: The method's last statement can probably
    be optimized a little ...

    --
     
    Eric Sosman, Feb 22, 2005
    #7
  8. Chris Uppal Guest

    Eric Sosman wrote:

    > Observation #2: The method's last statement can probably
    > be optimized a little ...


    <huge grin/>

    -- chris
     
    Chris Uppal, Feb 23, 2005
    #8
  9. Guest

    err... yes... i want to convert from EBCDIC to ASCII...
     
    , Feb 24, 2005
    #9
  10. Guest

    oh, and what does "return i != 0 ? 0 : 0" mean? if i not equals to 0,
    return something... i've never seen anything like that before.

    thanks all
     
    , Feb 24, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sylvain

    EBCDIC ascii conversion?

    Sylvain, Jun 13, 2004, in forum: Java
    Replies:
    2
    Views:
    21,990
    Thomas Weidenfeller
    Jun 14, 2004
  2. mike hengins

    ASCII TO EBCDIC: how ?

    mike hengins, Aug 29, 2005, in forum: Java
    Replies:
    1
    Views:
    3,167
    Roedy Green
    Aug 30, 2005
  3. Re: detecting ASCII/EBCDIC

    , Sep 2, 2008, in forum: C Programming
    Replies:
    3
    Views:
    398
  4. Antoninus Twink

    Re: detecting ASCII/EBCDIC

    Antoninus Twink, Sep 2, 2008, in forum: C Programming
    Replies:
    2
    Views:
    355
    Richard
    Sep 3, 2008
  5. Keith Thompson

    Re: detecting ASCII/EBCDIC

    Keith Thompson, Sep 3, 2008, in forum: C Programming
    Replies:
    2
    Views:
    336
    Keith Thompson
    Sep 3, 2008
Loading...

Share This Page