On Thu, Jan 13, 2011 at 4:35 AM, Jason Mcdonald <finn0013 / gmail.com> wrote:
> Nokogiri <i>is</i> easier... (see below)

Certainly!

> I would still like to know what exactly is causing the weird behavior in
> my original post though, if anyone knows. I can understand why encoding
> would result in incorrect parsing, but I don't understand why the
> encoding would mess up the hard coded portion of the call to puts still.

Can you provide a small program that exhibits the effect you are
seeing?  It is especially important to see how you calculate indexes.

Maybe this can help to illustrate a possible scenario:

Ruby version 1.9.2
irb(main):001:0> s =3D "a=E4"
=3D> "a=E4"
irb(main):002:0> s.encoding
=3D> #<Encoding:UTF-8>
irb(main):003:0> x =3D s.dup
=3D> "a=E4"
irb(main):004:0> x.encoding
=3D> #<Encoding:UTF-8>
irb(main):005:0> x.force_encoding "BINARY"
=3D> "a\xC3\xA4"
irb(main):006:0> x.encoding
=3D> #<Encoding:ASCII-8BIT>
irb(main):007:0> x[1,1]
=3D> "\xC3"
irb(main):008:0> s[1,1]
=3D> "=E4"
irb(main):009:0>

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/