Reputation: 1879
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?
Upvotes: 0
Views: 1010
Reputation: 27875
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')
Upvotes: 1
Reputation: 1830
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)
Upvotes: 0
Reputation: 6150
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)
Upvotes: 1