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.

"bös".chars.reverse is "s̈ob" for decomposed string

#597

Failing test attached.

I would make an attempt at patching this myself, but I'm not sure what would be preferred behavior.

Should chars normalize everything to NFKC? Should chars.to_s (assuming chars has not been modified) always return the original string, un-normalized?

Reported by Henrik Nyh · July 10th, 2008 @ 06:12 PM

State: committed
Milestone: 2.3.6
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. Henrik Nyh
    Henrik Nyh

    The failing test isn't likely something that would be used as-is if this issue is fixed, but is rather meant to illustrate the issue.

    July 10th, 2008 @ 06:13 PM

  2. josh
    josh
    • State changed from new to stale

    Staling out, please reopen if this is still a problem.

    October 28th, 2008 @ 04:24 PM

  3. Henrik Nyh
    Henrik Nyh

    Works fine in 2.2, so problem solved.

    October 28th, 2008 @ 04:30 PM

  4. Henrik Nyh
    Henrik Nyh

    Oops, no. I forgot that the ticket was about decomposed strings, specifically, and they still fail:

    
    >> dc = "bös".mb_chars.normalize(:kd).reverse.to_s
    => "s̈ob"
    

    I'm not empowered to reopen tickets, I think, but someone else please do.

    October 28th, 2008 @ 04:32 PM

  5. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from activesupport, bug, chars, multibyte, tested to activesupport, bug, bugmash, chars, multibyte, tested
    • Milestone cleared.

    August 3rd, 2009 @ 07:34 PM

  6. Dana Jones
    Dana Jones

    +1 - This is still a problem in 3.0. If you create an @string variable that equals "bös", then @string.chars.reverse has the desired result ("söb"), but @string.mb_chars.normalize(:kd).reverse.to_s outputs "s̈ob".

    August 9th, 2009 @ 11:48 PM

  7. Pratik
    Pratik
    • Assigned user set to Jeremy Kemper

    August 9th, 2009 @ 11:49 PM

  8. Elad Meidar
    Elad Meidar

    +1 indeed verified on master, unsuccessful to reproduce with other UTF8 strings (hebrew)

    August 10th, 2009 @ 12:05 AM

  9. Jeremy Kemper
    Jeremy Kemper
    • State changed from stale to open
    • Milestone set to 2.3.4

    August 10th, 2009 @ 05:51 AM

  10. Derander
    Derander

    +1 verified on master, this also happens w/ the string "bés"

    August 10th, 2009 @ 07:18 AM

  11. Jeremy Kemper
    Jeremy Kemper
    • State changed from open to incomplete

    Needs a fix.

    August 10th, 2009 @ 07:36 AM

  12. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.4 to 2.3.6

    [milestone:id#50064 bulk edit command]

    September 11th, 2009 @ 11:04 PM

  13. Matías Flores
    Matías Flores

    I've attached a patch that fixes this issue. It applies cleanly to both master and 2-3-stable.

    September 27th, 2009 @ 01:43 AM

  14. John Pignata
    John Pignata

    +1 - applies cleanly to master and 2-3-stable and tests pass

    September 27th, 2009 @ 05:14 AM

  15. sr.iniv.t
    sr.iniv.t

    +1 verified.

    The patch applies and all tests pass.

    September 27th, 2009 @ 05:38 AM

  16. Rishav Rastogi
    Rishav Rastogi

    +1 verified.

    Patch applies to master.

    September 27th, 2009 @ 07:20 AM

  17. CancelProfileIsBroken
    CancelProfileIsBroken
    • State changed from incomplete to open
    • Tag changed from activesupport, bug, bugmash, chars, multibyte, tested to activesupport, bug, bugmash, bugmash-review, chars, multibyte, tested

    September 27th, 2009 @ 11:32 AM

  18. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from activesupport, bug, bugmash, bugmash-review, chars, multibyte, tested to activesupport, bug, bugmash-review, chars, multibyte, tested

    September 27th, 2009 @ 12:31 PM

  19. Manfred Stienstra
    Manfred Stienstra
    • Tag changed from activesupport, bug, bugmash-review, chars, multibyte, tested to activesupport, bug, bugmash-review, chars, multibyte, tested

    Matías' fix looks good, it has my blessing (;

    In a pure theoretical sense this is the correct way of fixing the problem. This makes sure that elaborate Hangul strings get reversed properly as well. It is a bit slow though. I don't know of many real world cases where you would reverse a string, so I guess if you're doing it you probably have a great incentive to do it properly and you wouldn't mind the speed penalty.

    November 1st, 2009 @ 03:46 PM

  20. Repository
  21. Repository
  22. Rizwan Reza
    Rizwan Reza
    • Tag changed from activesupport, bug, bugmash-review, chars, multibyte, tested to activesupport, bug, chars, multibyte, tested

    May 15th, 2010 @ 06:42 PM