By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,123 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,123 IT Pros & Developers. It's quick & easy.

Reading raw data and writing out in EBCDIC format

P: n/a
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~@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^AAPzC^!^@^@7u^@^@^@^@Ca~@^@^@ ^@^@^@^@^@^@^@^@-------------------------------------------------
so...on

Any help would be greatly appreciated.

Thanks,
Ven.

Jul 12 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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
Jul 12 '06 #2

P: n/a
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.

Jul 12 '06 #3

P: n/a
"Ven" <ve*********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.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.com, and you're likely
to find the code you need.

-Howard

Jul 12 '06 #4

P: n/a
"Howard" <al*****@hotmail.comwrote in message
news:Dt********************@bgtnsc05-news.ops.worldnet.att.net...
>"Ven" <ve*********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googleg roups.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.com, 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:

http://www.dinkumware.com/manuals/?m...vt.html#ebcdic

HTH,

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 12 '06 #5

P: n/a
"Ven" <ve*********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.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^@^@^@^@^E27uAP(C]|
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^AAO33C\~@^@^@7u^@^@^@^@C]|
^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@%^O^@^@^@^G^@^@^@^@^ E37uAP(C]|
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^AAO33C\~@^@^@7u^@^@^@^@C]|
^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@%^O^@^@^@^G^@^@^@^@^ E47uAS\)Ca~@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^AAPzC^!^@^@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.
Jul 13 '06 #6

P: n/a
Ven
Hi,

Thanks Jim and Plauger.

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

Ven.

Jim Langston wrote:
"Ven" <ve*********@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.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^@^@^@^@^E27uAP(C]|
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^AAO33C\~@^@^@7u^@^@^@^@C]|
^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@%^O^@^@^@^G^@^@^@^@^ E37uAP(C]|
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^AAO33C\~@^@^@7u^@^@^@^@C]|
^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@%^O^@^@^@^G^@^@^@^@^ E47uAS\)Ca~@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^AAPzC^!^@^@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.
Jul 14 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.