diff options
author | Manfred Stienstra <manfred@fngtps.com> | 2009-11-02 21:34:07 +0100 |
---|---|---|
committer | Manfred Stienstra <manfred@fngtps.com> | 2009-11-04 10:14:49 +0100 |
commit | da3a228a93e1858a46f9a0cefcb9c72285479a56 (patch) | |
tree | 9c8cada860e22f3b2866e72f64a47dedf83f290c /activesupport/lib | |
parent | 62a022891b5f12284205920a03a3cbbe5b8ecd27 (diff) | |
download | rails-da3a228a93e1858a46f9a0cefcb9c72285479a56.tar.gz rails-da3a228a93e1858a46f9a0cefcb9c72285479a56.tar.bz2 rails-da3a228a93e1858a46f9a0cefcb9c72285479a56.zip |
Make ActiveSupport::Chars#limit run on Ruby 1.9.
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/multibyte/chars.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index 51b870de8c..d372b0ab1f 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -665,6 +665,11 @@ module ActiveSupport #:nodoc: def translate_offset(byte_offset) #:nodoc: return nil if byte_offset.nil? return 0 if @wrapped_string == '' + + if @wrapped_string.respond_to?(:force_encoding) + @wrapped_string = @wrapped_string.dup.force_encoding(Encoding::ASCII_8BIT) + end + begin @wrapped_string[0...byte_offset].unpack('U*').length rescue ArgumentError => e |