Brian Candler wrote in post #969026:
> The strings are "equal", in the sense that Ruby says a==b is true. But
> in ruby 1.9, some strings are more equal than others.
>
> The specific bug he's hit is reproduced here:
> http://www.ruby-forum.com/topic/476119#964668

Would it make sense than to include a method like
eql_with_encoding? on the String class?

$ irb  # removed the 'ruby-1.9.2-p0>' prompts
s1 = "hello"  #=> "hello"
s2 = "hello".force_encoding("US-ASCII")  #=> "hello"
class String
  def eql_with_encoding?(other)
    other.is_a?(String) && self.eql?(other) &&
      self.encoding.eql?(other.encoding)
  end
end
s1.eql?(s2)  #=> true
s1.eql_with_encoding?(s2)  #=> false

-- 
Posted via http://www.ruby-forum.com/.