Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7273

Show
Ignore:
Timestamp:
08/05/07 00:51:16 (1 year ago)
Author:
nzkoz
Message:

Make the utf-handler return the correct value for non-matching regular expressions. Closes #9049 [manfred]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r7272 r7273  
    11*SVN* 
     2 
     3* Make the utf-handler return the correct value for non-matching regular expressions. Closes #9049 [manfred] 
    24 
    35* Add ljust, rjust and center to utf8-handler. Closes #9165 [manfred] 
  • trunk/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb

    r7272 r7273  
    317317      # Used to translate an offset from bytes to characters, for instance one received from a regular expression match 
    318318      def translate_offset(str, byte_offset) 
     319        return nil if byte_offset.nil? 
    319320        return 0 if str == '' 
    320         return nil if byte_offset.nil? 
    321321        chunk = str[0..byte_offset] 
    322322        begin 
  • trunk/activesupport/test/multibyte_chars_test.rb

    r6882 r7273  
    8282      assert_equal 9, (@s[:utf8].chars =~ /ffi/), 
    8383        "Regex matching should be unicode aware" 
     84      assert_nil((''.chars =~ /\d+/), 
     85        "Non-matching regular expressions should return nil") 
    8486    end 
    8587  end 
     
    119121  def test_passthrough_on_kcode 
    120122    # The easiest way to check if the passthrough is in place is through #size 
    121     with_kcode('nonce') do 
     123    with_kcode('none') do 
    122124      assert_equal 26, @s[:utf8].chars.size 
    123125    end