Converting Pack/Unpacked EBCDIC file to ASCII

K

kristenzhang

Suppose I have a Pack/Unpacked EBCDIC file (.upd), what's the easist
way to convert it to an ASCII file (.dat)? Do I need a conversion
table and everything, or can I just do it with a simple Reader/Writer
in Java and do it per byte?? Also, I will have a copybook file to help
me convert & unpack. Please let me know if you have any suggestions!
Thanks lots!
 
R

Rhino

Suppose I have a Pack/Unpacked EBCDIC file (.upd), what's the easist
way to convert it to an ASCII file (.dat)? Do I need a conversion
table and everything, or can I just do it with a simple Reader/Writer
in Java and do it per byte?? Also, I will have a copybook file to help
me convert & unpack. Please let me know if you have any suggestions!
Thanks lots!
This has been discussed many times in the past. A Google Newsgroups search
should turn up the past discussions very quickly.

Rhino
 
R

Rhino

i've looked... and none was helpful...

Sorry, I just assumed that those old discussions would help you.

I don't have anything to add to what they say.

Rhino
 
A

Alex

public static int EBCDIC(int i)
{
if(i >= 65 && i <= 73)
return (i - 65) + 193;
if(i >= 74 && i <= 82)
return (i - 74) + 209;
if(i >= 83 && i <= 90)
return (i - 83) + 226;
if(i >= 97 && i <= 105)
return (i - 97) + 129;
if(i >= 106 && i <= 114)
return (i - 106) + 145;
if(i >= 115 && i <= 122)
return (i - 115) + 162;
if(i >= 48 && i <= 57)
return (i - 48) + 240;
if(i == 32)
return 64;
return i != 0 ? 0 : 0;
}

That's by definition. But be careful. Very. Because each application
has its own thoughts. For example, if you download text file via
mainframe ftp and then upload it via UNIX ftp result is different. Some
characters like | or ^Z are changed.
Alex Kizub.
 
E

Eric Sosman

Alex said:
public static int EBCDIC(int i)
{
if(i >= 65 && i <= 73)
return (i - 65) + 193;
if(i >= 74 && i <= 82)
return (i - 74) + 209;
if(i >= 83 && i <= 90)
return (i - 83) + 226;
if(i >= 97 && i <= 105)
return (i - 97) + 129;
if(i >= 106 && i <= 114)
return (i - 106) + 145;
if(i >= 115 && i <= 122)
return (i - 115) + 162;
if(i >= 48 && i <= 57)
return (i - 48) + 240;
if(i == 32)
return 64;
return i != 0 ? 0 : 0;
}

Observation #1: I think the O.P. wants to convert in
the other direction.

Observation #2: The method's last statement can probably
be optimized a little ...
 
K

kristenzhang

oh, and what does "return i != 0 ? 0 : 0" mean? if i not equals to 0,
return something... i've never seen anything like that before.

thanks all
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top