Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

String.mb_chars.upcase doesn't upcase non-ASCII chars on with Ruby 1.9.x

#4595

String#mb_chars does not currently return an instance of ActiveSupport::Multibyte::Chars under Ruby 1.9, leaving methods such as #upcase and #downcase up to Ruby 1.9's String class rather than a proxy.

At the time this code was developed, the assumption was that Ruby itself would provide this functionality in 1.9, so at the time the decision made perfect sense.

However, Matz has decided to leave UTF-8 case-folding out of Ruby 1.9, so there's currently no way to get UTF-8 aware upcasing/downcasing with Rails and Ruby 1.9:

Ruby 1.8.7:

"café".mb_chars.upcase # "CAFÉ"

Ruby 1.9.x

"café".mb_chars.upcase # "CAFé"

The patch I will attach makes AS use a proxy class on Ruby 1.9 to make the behavior consistent across Ruby versions. I also refactored all of AS's Unicode support into a new Unicode module to group related functionality and make it easier to reuse outside of ActiveSupport.

Reported by Norman Clarke · May 14th, 2010 @ 08:08 PM

State: resolved
Milestone: 3.0.2
Assigned to: nobody
Importance: Low

Activity

  1. Norman Clarke
    Norman Clarke
    • Tag changed from ruby 1.9.1, activesupport, multibyte to ruby 1.9.1, activesupport, multibyte, patch

    Patch attached.

    May 14th, 2010 @ 08:10 PM

  2. Jeremy Kemper
    Jeremy Kemper
    • Milestone cleared.
    • State changed from new to open

    Nice. Could you rebase against master?

    May 21st, 2010 @ 06:36 PM

  3. Norman Clarke
  4. Jeremy Kemper
  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM