Spreadsheet -0.6.5.1 "invalid encoding" Problem

T

Tadeusz Bochan

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] endand 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:in
`new'
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:in
`require'
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:in
`require'
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:in
`require'
from xls1:2
 
M

masa

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
 
T

Tadeusz Bochan

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
 
T

Tadeusz Bochan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top