From: Louis Krupp Date: 2003-03-05T18:19:08+09:00 Subject: Re: EBCDIC -> ASCII Matt Lawrence wrote: > It's also easily done using dd. The problem is that there are packed > decimal fields embedded in the record. Also, the tape this data is from > arrived without a data description. I was hoping to write a somewhat > generalized tool for interactively figuring out the format. I don't suppose you have the source for the COBOL program that originally read this stuff... :) Here's something that might help you build a map of which columns contain EBCDIC and which contain packed decimal: Read a record at a time, looking at the first column. If you see something that's not a valid EBCDIC representation of a printable character, mark the first column as packed decimal, rewind the file, and go on to the next column. If you reach the end of the file, mark the column as containing EBCDIC, rewind, and go on to the next column. When there are no more columns (hopefully, these are fixed length records with only one record type), you're done. If you invent an ASCII representation for the map, you can write it to a file and edit it as needed in case the automatic generation didn't quite get it right. With the record map in hand, you can use dd (or whatever) to do the translation and then paste fields back in from the original file. With any luck, you'll have something reasonably accurate. Louis