EBCDIC to ASCII conversion

Hi,
I have a input file which is EBCIDIC and it has packed decimals.
Can anyone help me to convert EBCIDIC file to ASCII(Need to convert even Packed decimal values also to normal format).

Thanks
swapna

EBC[i]DIC?

If you mean the same as EBCDIC in your header take a look at the dd command:

man dd

hi wisecracker ,

EBCIDIC file has packed decimals.Need to convert even Packed decimal values also to normal format.

Can you give me the full command which does the conversion from packed decimal to normal format

--- Post updated at 11:34 AM ---

Its EBCDIC format file

Then as far as I know there is no simple solution.

Does the system you are using NOT have a "proprietary" conversion program to do the task?

If not then it is going to require a serious script of your own to do it.

It might require that you hexdump the file first to covert to ASCII base 16 format, (0x97 for example), and test for nibbles in each.
This is in its simplest form. Negation or sign extension will need to be taken into account and without seeing a small dump of the file there is little help I can give at this point.

Write a cobol program.
Gnu-cobol is available at GnuCOBOL (formerly OpenCOBOL) download | SourceForge.net

If you don't know cobol, post the input file layout and i will write it for you.

1 Like

Post in an adequate forum! Don't post technical questions in "Post Here to Contact Site Administrators and Moderators"

Maybe I'm missing something, but wouldn't iconv do the job?
or dd if=your-ebcdic-file conv=ascii

1 Like

dd will only do a byte to byte conversion from EBCDIC to ascii. Packed decimal achieves data compression by using 4 bit bytes, essentially storing two decimal digits in a single byte.

1 Like

There're plenty of similar threads at the bottom of this in the 'More UNIX and Linux Forum Topics You Might Find Helpful' section.
Including this one by the usual "actors/participants".

The question is more like, how to convert the ASCII text 0xFFFF into a binary number. The text is ASCII, but the value it represents is binary. Packed decimals are kind of like that, encoded in a special BCD-ish IBM manner that's neither plaintext nor binary as it's usually done.

The sticking point is, they often end up in the middle of EBCDIC streams which look like text files but are really fixed-size database records completely lacking in metadata. Very COBOL-ish. Very IBM. And not actually a text file. dd or iconv can't generate a sensible result from

String1String2String3(BCD Garbage)String4String1String2String3(BCD Garbage)String4

So, there isn't any generic code to convert a text stream out of packed decimal, and can't be. You have to read the data in a structured way and know which bits to convert and how.

This is usually the point where we ask for the necessary sample of data, OP refuses, and the thread dies.

1 Like

Hi jgt ,

I cannot able to share the original input file,bcz its highly confidential data.we are not using mainframe environment setup.I need either unix command or some java programming.

Thanks
Swapna

What you are explaining looks very much cobol data file... in which case the easiest way out is to write a cobol program to read it and display/print the content, if that is fine, its very simple in cobol to write what need converting... and as already posted here, there is an open source cobol...

As Corona688 predicted, the OP is unwilling to share enough information for us to be able to help. Without details on the format of the file's contents, there is absolutely nothing that we can do to help decode the data that it contains.