Reading raw data and writing out in EBCDIC format

V

Ven

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^@^@^@^@^E27uAP(öC]|
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^AAO33C\~@ô^@^@7u^@^@^@^@C]|
^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@%^O^@^@^@^G^@^@^@^@^E37uAP(öC]|
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^AAO33C\~@ô^@^@7u^@^@^@^@C]|
^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@%^O^@^@^@^G^@^@^@^@^E47uAS\)Ca~@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^AAPzáC^!¥^@^@7u^@^@^@^@Ca~@^@^@^@^@^@^@^@^@^@^@-------------------------------------------------
so...on

Any help would be greatly appreciated.

Thanks,
Ven.
 
H

Howard

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.com, and you're likely
to find the code you need.

-Howard
 
P

P.J. Plauger

J

Jim Langston

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^@^@^@^@^E27uAP(öC]|
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^AAO33C\~@ô^@^@7u^@^@^@^@C]|
^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@%^O^@^@^@^G^@^@^@^@^E37uAP(öC]|
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^AAO33C\~@ô^@^@7u^@^@^@^@C]|
^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@%^O^@^@^@^G^@^@^@^@^E47uAS\)Ca~@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^AAPzá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 );
}

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

Ven

Hi,

Thanks Jim and Plauger.

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

Ven.
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top