Reading raw data and writing out in EBCDIC format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ven

    Reading raw data and writing out in EBCDIC format

    Hi,

    I am reading a kind of below mentioned raw data into my C++ program and
    writing it out but I want this to be converted into EBCDIC format, how
    can I accomplish this ?

    Right now I am using the following code

    ifstream Source("source_ file");
    ofstream Dest("dest_file ");
    Dest << Source.rdbuf();

    The above code just reads the below mentioned input data and writes it
    out as it is but I want this to be converted into EBCDIC format(sample
    data shown below) . Is there any EBCDIC conversions in C++.

    Input data:

    {00 00 00 00 00 00 00 01 00 00 % 0f 00 00 00 07 00 00 00 00 05 3 7 u A
    P ( f6 C ] a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    00 00 00 00 00 00 00 00 00 01 A O 3 3 C \ 80 f4 00 00 7 u 00 00 00 00 C
    ] a0 00 00 00 00 00}{00 00 00 00 00 00 00 01 00 00 % 0f 00 00 00 07 00
    00 00 00 05 5 7 u A S \ ) C a 80 00 00 00 00 00 00 00 00 00 00 00 00 00
    00
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    so...on

    Expecting output (in EBCDIC) :

    ^@^@^@^@^@^@^@^ A^@^@%^O^@^@^@^ G^@^@^@^@^E27uA P(öC]|
    ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^AAO 33C\~@ô^@^@7u^@ ^@^@^@C]|
    ^@^@^@^@^@^@^@^ @^@^@^@^@^A^@^@ %^O^@^@^@^G^@^@ ^@^@^E37uAP(öC]|
    ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^AAO 33C\~@ô^@^@7u^@ ^@^@^@C]|
    ^@^@^@^@^@^@^@^ @^@^@^@^@^A^@^@ %^O^@^@^@^G^@^@ ^@^@^E47uAS\)Ca ~@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^A APzáC^!¥^@^@7u^ @^@^@^@Ca~@^@^@ ^@^@^@^@^@^@^@^ @-------------------------------------------------
    so...on

    Any help would be greatly appreciated.

    Thanks,
    Ven.

  • Victor Bazarov

    #2
    Re: Reading raw data and writing out in EBCDIC format

    Ven wrote:
    [..] Is there any EBCDIC conversions in C++.
    If this is a question, the answer is "no".
    [..]
    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • Rolf Magnus

      #3
      Re: Reading raw data and writing out in EBCDIC format

      Victor Bazarov wrote:
      Ven wrote:
      >[..] Is there any EBCDIC conversions in C++.
      >
      If this is a question, the answer is "no".
      Well, there may be, but there is no way to find out.

      Comment

      • Howard

        #4
        Re: Reading raw data and writing out in EBCDIC format

        "Ven" <venupp.ravi@gm ail.comwrote in message
        news:1152734194 .694571.283240@ p79g2000cwp.goo glegroups.com.. .
        Hi,
        >
        I am reading a kind of below mentioned raw data into my C++ program and
        writing it out but I want this to be converted into EBCDIC format, how
        can I accomplish this ?
        >
        Right now I am using the following code
        >
        ifstream Source("source_ file");
        ofstream Dest("dest_file ");
        Dest << Source.rdbuf();
        >
        The above code just reads the below mentioned input data and writes it
        out as it is but I want this to be converted into EBCDIC format(sample
        data shown below) . Is there any EBCDIC conversions in C++.
        >
        There is no feature of the language that will do that for you. But I'd bet
        it's been done before. Try searching on groups.google.c om, and you're likely
        to find the code you need.

        -Howard



        Comment

        • P.J. Plauger

          #5
          Re: Reading raw data and writing out in EBCDIC format

          "Howard" <alicebt@hotmai l.comwrote in message
          news:Dtetg.3732 12$Fs1.27664@bg tnsc05-news.ops.worldn et.att.net...
          >"Ven" <venupp.ravi@gm ail.comwrote in message
          >news:115273419 4.694571.283240 @p79g2000cwp.go oglegroups.com. ..
          >Hi,
          >>
          >I am reading a kind of below mentioned raw data into my C++ program and
          >writing it out but I want this to be converted into EBCDIC format, how
          >can I accomplish this ?
          >>
          >Right now I am using the following code
          >>
          >ifstream Source("source_ file");
          >ofstream Dest("dest_file ");
          >Dest << Source.rdbuf();
          >>
          >The above code just reads the below mentioned input data and writes it
          >out as it is but I want this to be converted into EBCDIC format(sample
          >data shown below) . Is there any EBCDIC conversions in C++.
          >>
          >
          There is no feature of the language that will do that for you. But I'd
          bet it's been done before. Try searching on groups.google.c om, and you're
          likely to find the code you need.
          The codecvt facet you need (and instructions for using it) is a standard
          part of our latest library. See our web site, in particular the manual
          page:



          HTH,

          P.J. Plauger
          Dinkumware, Ltd.



          Comment

          • Jim Langston

            #6
            Re: Reading raw data and writing out in EBCDIC format

            "Ven" <venupp.ravi@gm ail.comwrote in message
            news:1152734194 .694571.283240@ p79g2000cwp.goo glegroups.com.. .
            Hi,

            I am reading a kind of below mentioned raw data into my C++ program and
            writing it out but I want this to be converted into EBCDIC format, how
            can I accomplish this ?

            Right now I am using the following code

            ifstream Source("source_ file");
            ofstream Dest("dest_file ");
            Dest << Source.rdbuf();

            The above code just reads the below mentioned input data and writes it
            out as it is but I want this to be converted into EBCDIC format(sample
            data shown below) . Is there any EBCDIC conversions in C++.

            Input data:

            {00 00 00 00 00 00 00 01 00 00 % 0f 00 00 00 07 00 00 00 00 05 3 7 u A
            P ( f6 C ] a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
            00 00 00 00 00 00 00 00 00 01 A O 3 3 C \ 80 f4 00 00 7 u 00 00 00 00 C
            ] a0 00 00 00 00 00}{00 00 00 00 00 00 00 01 00 00 % 0f 00 00 00 07 00
            00 00 00 05 5 7 u A S \ ) C a 80 00 00 00 00 00 00 00 00 00 00 00 00 00
            00
            -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            so...on

            Expecting output (in EBCDIC) :

            ^@^@^@^@^@^@^@^ A^@^@%^O^@^@^@^ G^@^@^@^@^E27uA P(öC]|
            ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^AAO 33C\~@ô^@^@7u^@ ^@^@^@C]|
            ^@^@^@^@^@^@^@^ @^@^@^@^@^A^@^@ %^O^@^@^@^G^@^@ ^@^@^E37uAP(öC]|
            ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^AAO 33C\~@ô^@^@7u^@ ^@^@^@C]|
            ^@^@^@^@^@^@^@^ @^@^@^@^@^A^@^@ %^O^@^@^@^G^@^@ ^@^@^E47uAS\)Ca ~@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^A APzáC^!¥^@^@7u^ @^@^@^@Ca~@^@^@ ^@^@^@^@^@^@^@^ @-------------------------------------------------
            so...on

            Any help would be greatly appreciated.

            Thanks,
            Ven.

            I would think an easy way to do this is just to build a table of 255
            characters that are the EBCDIC equivalents to the ASCII values. Something
            like:

            char* EBCDIC = "\x31\x22\x33.. ." (whatever the epsidic values are).

            Then go through the data read and write the EBCDIC value.

            for ( int i = 0; i < ReadData.length (); ++i )
            {
            Dest << EBCDIC( ReadData[i] );
            }

            You'll need translations for special characters (carriage return line feed
            conversions, etc..).

            There is probably source you can find on the net that probably already does
            this for you.

            If you are using an AS/400 there are methods to do this when you receive the
            file automatically, or use the client access software to convert it.


            Comment

            • Ven

              #7
              Re: Reading raw data and writing out in EBCDIC format

              Hi,

              Thanks Jim and Plauger.

              I am looking into your solutions. How to implement them ?

              Ven.



              Jim Langston wrote:
              "Ven" <venupp.ravi@gm ail.comwrote in message
              news:1152734194 .694571.283240@ p79g2000cwp.goo glegroups.com.. .
              Hi,
              >
              I am reading a kind of below mentioned raw data into my C++ program and
              writing it out but I want this to be converted into EBCDIC format, how
              can I accomplish this ?
              >
              Right now I am using the following code
              >
              ifstream Source("source_ file");
              ofstream Dest("dest_file ");
              Dest << Source.rdbuf();
              >
              The above code just reads the below mentioned input data and writes it
              out as it is but I want this to be converted into EBCDIC format(sample
              data shown below) . Is there any EBCDIC conversions in C++.
              >
              Input data:
              >
              {00 00 00 00 00 00 00 01 00 00 % 0f 00 00 00 07 00 00 00 00 05 3 7 u A
              P ( f6 C ] a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
              00 00 00 00 00 00 00 00 00 01 A O 3 3 C \ 80 f4 00 00 7 u 00 00 00 00 C
              ] a0 00 00 00 00 00}{00 00 00 00 00 00 00 01 00 00 % 0f 00 00 00 07 00
              00 00 00 05 5 7 u A S \ ) C a 80 00 00 00 00 00 00 00 00 00 00 00 00 00
              00
              -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
              so...on
              >
              Expecting output (in EBCDIC) :
              >
              ^@^@^@^@^@^@^@^ A^@^@%^O^@^@^@^ G^@^@^@^@^E27uA P(öC]|
              ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^AAO 33C\~@ô^@^@7u^@ ^@^@^@C]|
              ^@^@^@^@^@^@^@^ @^@^@^@^@^A^@^@ %^O^@^@^@^G^@^@ ^@^@^E37uAP(öC]|
              ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^AAO 33C\~@ô^@^@7u^@ ^@^@^@C]|
              ^@^@^@^@^@^@^@^ @^@^@^@^@^A^@^@ %^O^@^@^@^G^@^@ ^@^@^E47uAS\)Ca ~@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^A APzáC^!¥^@^@7u^ @^@^@^@Ca~@^@^@ ^@^@^@^@^@^@^@^ @-------------------------------------------------
              so...on
              >
              Any help would be greatly appreciated.
              >
              Thanks,
              Ven.
              >
              I would think an easy way to do this is just to build a table of 255
              characters that are the EBCDIC equivalents to the ASCII values. Something
              like:
              >
              char* EBCDIC = "\x31\x22\x33.. ." (whatever the epsidic values are).
              >
              Then go through the data read and write the EBCDIC value.
              >
              for ( int i = 0; i < ReadData.length (); ++i )
              {
              Dest << EBCDIC( ReadData[i] );
              }
              >
              You'll need translations for special characters (carriage return line feed
              conversions, etc..).
              >
              There is probably source you can find on the net that probably already does
              this for you.
              >
              If you are using an AS/400 there are methods to do this when you receive the
              file automatically, or use the client access software to convert it.

              Comment

              Working...