From cb927c8774f98c979b4e0466798d74bdd23a79f2 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Thu, 12 Oct 2006 21:00:34 +0000 Subject: Make String#chars slicing behaviour consistent with String. Closes #6387 [Manfred Stienstra] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5286 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb b/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb index c6ef6ad095..6c8eb88702 100644 --- a/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb +++ b/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb @@ -162,10 +162,10 @@ module ActiveSupport::Multibyte::Handlers elsif args[0].kind_of? Range cps = u_unpack(str).slice(*args) cps.nil? ? nil : cps.pack('U*') - elsif args[0].kind_of? Numeric + elsif args.size == 1 && args[0].kind_of?(Numeric) u_unpack(str)[args[0]] else - str.slice(*args) + u_unpack(str).slice(*args).pack('U*') end end alias_method :[], :slice @@ -434,4 +434,4 @@ module ActiveSupport::Multibyte::Handlers UCD = UnicodeDatabase.new end end -end \ No newline at end of file +end -- cgit v1.2.3