Changeset 5286
- Timestamp:
- 10/12/06 21:00:34 (2 years ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb (modified) (1 diff)
- trunk/activesupport/test/multibyte_handler_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r5224 r5286 1 1 *SVN* 2 3 * Make String#chars slicing behaviour consistent with String. Closes #6387 [Manfred Stienstra] 2 4 3 5 * Pull in latest multibye patch. Closes #6346 [Manfred Stienstra] trunk/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb
r5224 r5286 163 163 cps = u_unpack(str).slice(*args) 164 164 cps.nil? ? nil : cps.pack('U*') 165 elsif args [0].kind_of? Numeric165 elsif args.size == 1 && args[0].kind_of?(Numeric) 166 166 u_unpack(str)[args[0]] 167 167 else 168 str.slice(*args)168 u_unpack(str).slice(*args).pack('U*') 169 169 end 170 170 end trunk/activesupport/test/multibyte_handler_test.rb
r5224 r5286 158 158 assert_equal '', @handler.slice('', 0..10), "Empty string should not break things" 159 159 assert_equal "d Ðлå ï¬", @handler.slice(@string, 3..9), "Unicode characters have to be returned" 160 assert_equal "d Ðлå ï¬", @handler.slice(@string, 3, 7), "Unicode characters have to be returned" 161 assert_equal "A", @handler.slice(@string, 0, 1), "Slicing from an offset should return characters" 160 162 assert_equal " Ðлå ï¬ ", @handler.slice(@string, 4..10), "Unicode characters have to be returned" 161 163 assert_equal "", @handler.slice(@string, 7..6), "Range is empty, should return an empty string"