473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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~@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^AAPzáC^!¥^@^@7u^@^@^@^@Ca~@^@^@ ^@^@^@^@^@^@^@^@-------------------------------------------------
so...on

Any help would be greatly appreciated.

Thanks,
Ven.

Jul 12 '06 #1
6 2588
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~@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^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[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~@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^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[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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeevan | last post by:
Hi, I have an array of data (which I am getting from a socket connection). I am working on a program which acts on this data but the program is written to work on data from a file (not from an...
3
by: KevinD | last post by:
thank you for your helpful explanations. In my first note I forgot to mention that my simple flatfile is a text file with a newline character at the end thus I able to get an entire record . ...
6
by: R.A. | last post by:
Hi Is there some support for this file conversion in c#? Thanks
2
by: Ranjan | last post by:
Hi folks! I am trying to convert EBCDIC file to ASCII file. the issues are 1) Can all EBCDIC file be converted to ASCII without loss of information.(There is one character cent sign which is not...
9
by: jeff M via .NET 247 | last post by:
I'm still having problems reading EBCDIC files. Currently itlooks like the lower range (0 to 127) is working. I have triedthe following code pages 20284, 20924, 1140, 37, 500 and 20127.By working I...
9
by: dba123 | last post by:
I need some help and direction on what classes and an example or two (article) on how to read an Excel Worksheet and insert one column into a database table column. I am using .NET 2.0 only. What...
0
by: Srini | last post by:
Hello, Using unload JCL utility DSNUPROC I unloaded a table(which is in unicode) to a dataset. I want the unload to be in EBCDIC format. I used the unload option EBCDIC, but I am not able to...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
9
by: Bill Woessner | last post by:
Suppose I have a structure, foo, which is a POD. I would like to read and write it to disk as follows: std::ofstream outs; foo bar; outs.write(reinterpret_cast<char*>(&bar), sizeof(foo));...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.