Nobuyoshi N. wrote:
OK, then can’t you show the iconv.rb which causes the problem?
`gem which -a iconv’ shows the all paths.
[root~/ruby/docsearch/app/controllers] gem which -a iconv
/usr/local/lib/ruby/1.9.1/x86_64-linux/iconv.so
Like i said, AFAIK there is no “iconv.rb” on my system. But the error
in my OP was the cut n’ pasted error, no typo:
iconv.rb:7:in `<top (required)>’: uninitialized constant Iconv
However, the path (which I removed) is the path of my script
(/root/ruby/) which does not contain an icon.rb either.
I am very new to ruby. I wrote the script, as I said, it worked fine,
then I moved the code to my controller and added ‘require “iconv”’ at
the top – although I am not sure if there are more caveats in rails (or
whatever, etc). Anyway, after that did not work, probably I checked the
syntax and decided that I could not see a problem, then I went to back
to the script, and probably fooled around with that for half an hour
presuming I was confused until, as mentioned, I had the problem with a
two line script, rebooted, same deal.
However, ahem I just went and tested the original test script:
require “iconv”
file=File.new("/usr/share/doc/HTML/httpd-docs-2.2.2.en/mod/mod_expires.html",“r”);
lines=file.lines.to_a
file.close
conv=Iconv.new(“UTF-8//TRANSLIT//IGNORE”,“ISO_8859-1”,)
x = Array.new
lines.each { |l|
tmp=conv.iconv(l)
x.push tmp.gsub!(/<[^>]*>/,"")
}
x.delete_if{|l| l !~ /\w/}
x.each { |l| puts l }
and it works with no complaint now.
I just want to be honest with you. I have been programming full time
for several years (C and perl) and this is the first time I have
actually filed a bug report with anybody. If this happens again, I
will try and garner more details.
Sorry – but thanks for your vigilance. Still curious about where
“iconv.rb” is tho, and why the API does not refer to the environment
variables you mention.
MK