encoding issue

I'm having a problem with output gleaned from searching ISO-8859-9 web
pages.

I thought I had rectified this by opening the pages "r:ISO...", and by
using .force_encoding and .encode! with the lines. This seems to work,
as according to logger.info output, execution makes it all the way
through the controller AND the view code...meaning I would have thought
there is nothing left for me to do.

After the controller code has run I get:
Rendering docsearch/search
Then the view code runs and I get:
Completed in 1179ms (View: 11, DB: 1) | 200 OK
[http://localhost/docdir/search]

THEN,
Processing ApplicationController#search
which seems strange, since
Processing DocdirController#search
already happened. I had not noticed this before; what is the difference
between these two, and what is the significance of "Processing
ApplicationController#search" AFTER the view is already complete?

Anyway, that's when I get
ArgumentError (invalid byte sequence in UTF-8):
  <internal:prelude>:8:in `synchronize'
  /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
  /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
  /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in
start_thread'

So I have tried setting both internal and external encodings:
Encoding.default_external = @dir.encoding
Encoding.default_internal = @dir.encoding
In the hopes that this would mean everything -- parsing, IO, etc. will
be done in ISO-8859-1, but obviously this is not the case. I presume I
cannot set the encoding for the scripts that aren't mine, ie, the
webrick scripts that are throwing this error.

What can I do? AFAICT, all my code has executed without error, every
line dealt with is output via the logger, in the controller AND in the
view, A-ok, and then this happens? Why can I not just set *everything*
to one encoding for a duration? Is it webrick? I also tried using
Encoding::Converter on everything read in, to no avail...Help!

--MK

Well, I solved it using Encoding::Convert. The difference between
"each" (which does not allow in place changes) and "each_with_index" had
me hung up. Ruby newbie!

I would still LOVE to know why/how iconv self-destructed tho...