Hi -- On Wed, 5 Mar 2003, Wesley J Landaker wrote: > 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 ;) Also: candle:~$ irb --simple-prompt >> VERSION => "1.8.0" >> require 'iconv' => true >> Iconv.iconv("EBCDIC-US", "ASCII", "this is in ASCII") => ["\243\210\211\242@\211\242@\211\225@\301\342\303\311\311"] (I think this is/was new with 1.7.) David -- David Alan Black home: dblack / superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav