Board index » delphi » ebcdic/binary guru's

ebcdic/binary guru's

Hi,

I have been given a large 37 meg file in ebcdic format. (From a tape)

No they won't translate it to ascii for me on the mainframe.

I have to read and translate this myself.

Firstly ; can this be done ?

I have written a little routine to read the file in (parts of it)
in file of byte format.

I am assuming things like - ebcdic charactors are 8 bits ?

I am not using char which is unsigned ?

if they give me things like columns 1 to 6 - is number field Alpha

Then the first six bytes of each 160 byte record should be the number.

 field. (yes they say it is a 160 byte record)

I cannot find one hex value in these bytes that correspond to anything
like numbers or numbers that go 1 2 3 4 5 etc

Any comments, source, tips, reference sources would be greatly
appreciated.

Regards
Byron

 

Re:ebcdic/binary guru's


Hi Byron -

It's certainly possible to convert from EBCDIC to ASCII, but the first
thing to be careful of is *which* version of EBCDIC. It's my understanding
that there is more than one. Ask "they" what particular operating system
the file comes from and whether they know what version of EBCDIC is being
used.

If you did some web searches on "ebcdic" and "ebcdic ascii conversion" I
bet you'll come up with lots of useful stuff.

Quote
> I am assuming things like - ebcdic charactors are 8 bits ?

7 or 8 bits, but you can read them into bytes just the same.

Quote
> I am not using char which is unsigned ?

Well, "char" is a character which isn't really signed or unsigned, but the
underlying range is unsigned (0..255). "Byte" is an 8-bit unsigned value in
the range 0..255. This would be the same for both ASCII and EBCDIC, AFAIK.

Quote
> if they give me things like columns 1 to 6 - is number field Alpha
> Then the first six bytes of each 160 byte record should be the number.
> field. (yes they say it is a 160 byte record)

Very often these mainframe files come in fixed-length record formats. The
first six bytes of a "record" (one line in the file) will evaluate to a
number (most likely specified in  numeric characters) once you've converted
the bytes from EBCDIC representation to ASCII representation. That is to
say...

Quote
> I cannot find one hex value in these bytes that correspond to anything
> like numbers or numbers that go 1 2 3 4 5 etc

... don't bother trying to understand the contents of these records until
you've converted them to ASCII.

Quote
> Any comments, source, tips, reference sources would be greatly
> appreciated.

Try a web search, and try Garbo and X2FTP to see if they have anything. Now
I'm curious so I'll probably look on the web too, and if I find anything,
I'll bring it back to the group.

Cheers, Todd

Re:ebcdic/binary guru's


Quote
byron coetzee wrote:
> I have been given a large 37 meg file in ebcdic format. (From a tape)
> ...
> I have to read and translate this myself.
> Firstly ; can this be done ?

Yes, if they tell you, and then you tell us, what kind of data should
be parsed.

Quote
> I am assuming things like - ebcdic charactors are 8 bits ?

Yes.  And once you get to know WHICH ebcdic has been used in the
file you will be able to translate it thru a char-to-char table
to your ascii.

Quote
> I cannot find one hex value in these bytes that correspond to anything
> like numbers or numbers that go 1 2 3 4 5 etc

In case this could be of any help, ebcdic -> ascii:

  $40 = space
  $81..$89 = a..i
  $91..$99 = j..r  
  $a2..$a9 = s..z
  $c1..$c9 = A..I
  $d1..$d9 = J..R  
  $e2..$e9 = S..Z
  $f0..$f9 = 0..9

--
    "La esperanza es lo ultimo que se pierde. Y es un pena,
    porque si se perdiera lo primero, quiza se hiciera algo
    para solucionar las cosas." - J. Perich

Other Threads