Multibye chars eql?

I just upgraded an application to 2.3 RC2 and had several failing
features stemming from ActiveSupport::Multibyte::Chars #eql? behaving
differently in Ruby 1.8.x from 1.9.

There was an old ticket with a patch and then some suggestions for
fixing it that had be come stale, so I created a new patch
incorporating the suggestion.

http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1496

I'd appreciate it if someone could check it out and apply it for 2.3.

Thanks,
Brandon

Hi Brandon,

The reason I dropped Chars#eql? is because I wanted String#eql? and
Chars#eql? to be symmetric. This can't be done without redefining
String#eql? and I felt at the time that redefining core lib methods
might be a bit much.

I guess if the core team doesn't mind changing String#eql? I wouldn't
mind either. But the patch doesn't really make and sense without it.

I definately don't feel alright with implementing Chars#hash, because
of the internal optimizations of Hash in Ruby you can never get this
to work consistently. It's better to not support it at all than doing
a half-assed job.

If you want to implement eql?, please open a new ticket because the
ticket you're referring to was more about hash access than eql?.

Manfred

The issue that prompted me to revive this is actually related to hash access. Here’s what I was doing:

@clients.group_by {|p| p.name.mb_chars.first }

This gives me back an array that is the same size as the original @clients array because it sees each Chars string as different.

I understand your desire for it to be symmetric with String#eql?, but I think that is a separate issue. I don’t feel strongly about it one way or the other. At a minimum, #eql? and #hash should behave properly when compared to another Chars object.

Brandon

PGP.sig (194 Bytes)