468,468 Members | 2,727 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,468 developers. It's quick & easy.

Reading raw data and writing out in EBCDIC format

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
6 2274
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
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
"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
"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
"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
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.

Similar topics

3 posts views Thread by KevinD | last post: by
6 posts views Thread by R.A. | last post: by
2 posts views Thread by Ranjan | last post: by
9 posts views Thread by jeff M via .NET 247 | last post: by
9 posts views Thread by dba123 | last post: by
6 posts views Thread by arne.muller | last post: by
9 posts views Thread by Bill Woessner | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.