0

I used to do it fine with:

Iconv.iconv('ASCII', 'EBCDIC-US', someEBCDICstring)

since ruby 1.9 I get that warning:

iconv will be deprecated in the future, use String#encode instead.

but I can't find any reference of EBCDIC or cp37, cp500, cp875... in the Encoding class:

p Encoding.name_list

Am I supposed to import it from somewhere? Can I add it myself?

Victor
  • 1,680
  • 3
  • 22
  • 40

3 Answers3

1

You can still use the gem - https://rubygems.org/gems/iconv

(And here are the docs - http://rubydoc.info/gems/iconv/1.0.3/frames)

AndrewPK
  • 6,100
  • 3
  • 32
  • 36
1

In Ruby 2.3 the EBCDIC-encoding is added:

Encoding

new Encoding::IBM037 (alias ebcdic-cp-us; dummy)

So this should work:

str = 'xx'
str.encode('IBM037')
knut
  • 27,320
  • 6
  • 84
  • 112
0
require 'iconv' # sudo apt-get install ruby-dev && sudo gem install iconv

This works for me...

# set up translation to EBCDIC
trsl = Iconv.new('EBCDIC-US','ASCII')

# translate value
ebcdic = trsl.iconv(somestring)
mckenzm
  • 1,545
  • 1
  • 12
  • 19