This project is archived and is in readonly mode.
ActiveSupport::Multibyte::Chars
-
Erik Ostrom
Verified, test and patch forthcoming.
-
Erik Ostrom
I've attached a patch (including a test).
-
Jeremy Kemper
- Assigned user set to Jeremy Kemper
- State changed from new to open
- Milestone set to 2.3.4
Good catch. Could you use
git format-patchinstead of diff? -
Elad Meidar
- Assigned user cleared.
"Patch does not have a valid email address", attached a working patch.
-
Elad Meidar
Patch applies to master, tests pass as well.
-
Erik Ostrom
I've attached a patch again, format-patch style.
-
Jeremy Kemper
- Assigned user set to Jeremy Kemper
On Ruby 1.9:
1) Failure: test_rindex_should_return_character_offset(MultibyteCharsUTF8BehaviourTest) [test/multibyte_chars_test.rb:241]: 12 expected but was 13.
-
Jeremy Kemper
- State changed from open to incomplete
Applied to master (prematurely): 4dda9b644df5e4386f693a4b7bd00fe787f41a28
Need to be compat with 1.9 before 2-3-stable backport.
-
Elad Meidar
- Assigned user cleared.
i was having a problem with the functionality using RTL languages as values, since rindex always scans left to right, strings were truncated in the wrong way.
-
Jeremy Kemper
- Assigned user set to Jeremy Kemper
-
Erik Ostrom
- Assigned user cleared.
Ruby 1.9 helpfully points out that my test is wrong - which means my implementation is, too. Developing...
-
Erik Ostrom
I've attached a patch to be applied after my earlier one. The test is fixed so it passes on Ruby 1.9, and the implementation is fixed so it passes the fixed test. The offset parameter wasn't being translated into bytes before calling the underlying string method.
index had an equivalent bug, which went unnoticed because the test cases all used the default offset, and a 0-character offset translates to 0 bytes. I added some offset tests and fixed the bug in #index.
I also threw in a couple of negative-offset tests, inspired by #2428 Unicode-aware rindex method, of which this ticket is a duplicate. (Andy Stewart's patch from that one no longer applies cleanly to master, but I wish I'd noticed it earlier.)
These tests passed (for me) on Ruby 1.9.2 Preview 1 and Ruby 1.8.6.
-
Repository
- State changed from incomplete to committed
(from [7d16e94d827197d030fdd611db4310396aeb0114]) Correctly handle offsets in Multibyte::Chars#index and #rindex.
The offset in codepoints was being passed directly to the wrapped string's index/rindex method. Now we translate the offset into bytes first.
[#3028 ActiveSupport::Multibyte::Chars state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/7d16e94d827197d030fdd611db4310... -
Repository
(from [4e014379a3c792281138c5a19a5bd74e9435fede]) Correctly handle offsets in Multibyte::Chars#index and #rindex.
The offset in codepoints was being passed directly to the wrapped string's index/rindex method. Now we translate the offset into bytes first.
[#3028 ActiveSupport::Multibyte::Chars state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/4e014379a3c792281138c5a19a5bd7... -
Jeremy Kemper
- Tag changed from 2, 2.3.x, 3, 3.0, bugmash, multibyte to 2, 2.3.x, 3, 3.0, multibyte
-
Rizwan Reza
- State changed from committed to resolved
-
Jeremy Kemper
Rizwan, committed == resolved.
-
Andrea Campi
- Tag changed from 2, 2.3.x, 3, 3.0, multibyte to 2-3-stable, 2.3.x, 3, 3.0, multibyte
- Importance changed from to
