Spreadsheet -0.6.5.1 "invalid encoding" Problem

Hi,
I just gem installed spreadsheet and tried the example ,
(Ruby 1.8.6 on HP-UX)
<<
require ‘spreadsheet’
book = Spreadsheet.new ‘excel-file.xls’
sheet = book.worksheet 0
sheet.each do |row| puts row[0] end

and was rewarded with the stack trace below.
Can anyone give me a clue as to what I’m missing or what can I do to fix
it ?
Thanks,
Tad
END
/home/acore/ruby/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/types/base.rb:42:in
initialize': invalid encoding ("utf-8", "utf- 16le") (Iconv::InvalidEncoding) from /home/acore/ruby/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/types/base.rb:42:innew’
from
/home/acore/ruby/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/types/base.rb:42
from
/home/acore/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /home/acore/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/home/acore/ruby/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/types.rb:1
from
/home/acore/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /home/acore/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/home/acore/ruby/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/storage/base.rb:6
… 14 levels…
from
/home/acore/ruby/lib/ruby/gems/1.8/gems/spreadsheet-0.6.5.1/lib/spreadsheet.rb:27
from
/home/acore/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
gem_original_require' from /home/acore/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire’
from xls1:2

Hi,

/home/acore/ruby/lib/ruby/gems/1.8/gems/ruby-ole-1.2.11.1/lib/ole/types/base.rb:42:in

`initialize’: invalid encoding (“utf-8”, “utf-
16le”) (Iconv::InvalidEncoding)
from

It looks an error from Iconv library, I guess the encoding from utf-8
to utf-16le failed.
The Iconv library is a wrapper library of iconv() function on a system.
It means Iconv works differently depending on a system.
For example, try to type the following on a console,

iconv -l

If you cannot find ‘utf-8’ and ‘utf-16le’ on the result, then you
cannot convert ‘utf-8’ to ‘utf-16le’.
Try to run the same script on a different environment, I mean a
different OS. It may work.

Best regards
Masa

masa wrote in post #976743:

Hi,
Try to run the same script on a different environment, I mean a
different OS. It may work.

Best regards
Masa

Hi Masa, thanks for the info.
The code does in fact work in windows, so I will try the iconv -1 when
I’m next in the office. HPUX is definitely not friendly to Ruby. There
seems to be a problem with installing anything at all.
I usually end up have to do some post-install fixups, where I don’t
really know what I’m doing !!!.
I feel I was lucky to have been able to install Ruby itself on HPUX.
I’ll let you know how I get on,
Thanks again,
Tad

Hi, Tad,

so I will try the iconv -1

Not ‘iconv -1’, but

iconv -l

Small ‘L’

or

iconv --list

also works.

Good luck.
Masa

2011/1/23 Tadeusz B. [email protected]:

Hi Masa,

Told you HPUX was , er, different !
The only options are -f & -t

:tadb> iconv --list
iconv: usage: iconv -f fromcode -t tocode [files …]
tadb> iconv -l
iconv: usage: iconv -f fromcode -t tocode [files …]
:tadb>

In any case, I think the following grep tells me that utf16
is not supported.

:tadb>grep -i utf16 /usr/lib/nls/iconv/config.iconv
;tadb>
:tadb> iconv -f utf8 -t iso81 convfile
xxxxxxxxxxxxxxxxxx

:tadb> iconv -f utf8 -t utf16le convfile
iconv: can not initialize the conversion
:tadb>
Thanks Masa.