On Tuesday 04 March 2003 2:59 pm, Matt Lawrence wrote:
> I'm trying to write a Ruby script that will translate data in EBCDIC
> and packed BCD format into ASCII and then into a MySQL database. 
> There are some very handy pack and unpack functions for strings, but
> I don't see any translation from EBCDIC.  Does anyone have a useful
> module for doing this?

It's not ruby, but translating EBCDIC to ASCII is easily done with 
iconv. It's part of the glibc distribution, so it should be available 
anywhere you have glibc (i.e. linux, windows w/ cygwin, etc.)

Now, as far as *using* it from ruby, you could do something like this:

iconv = IO.popen("iconv -f EBCDIC-US -t ASCII", "r+")
iconv.puts("this is in ASCII")
iconv.close_write
iconv.gets #=>"210\211¡Ö@\211¡Ö@\211\225@¥ÁäťΥÎ%"

(which is in EBCDIC-US, although it might not be by the time my mail 
agent translates it to UTF-8 ;)

-- 
Wesley J. Landaker - wjl / icecavern.net
OpenPGP FP: C99E DF40 54F6 B625 FD48  B509 A3DE 8D79 541F F830