From 16cef77d37ffe3e2cdc6f7db76b4ae59ce4cbc5b Mon Sep 17 00:00:00 2001 From: James MacAulay Date: Tue, 18 May 2010 15:19:53 -0400 Subject: Fix AS::MB::Chars#+ to not alter self [#4646 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activesupport/lib/active_support/multibyte/chars.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/multibyte') diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index c107aad6bb..1134d1ccc6 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -105,7 +105,7 @@ module ActiveSupport #:nodoc: # Example: # ('Café'.mb_chars + ' périferôl').to_s #=> "Café périferôl" def +(other) - self << other + chars(@wrapped_string + other) end # Like String#=~ only it returns the character offset (in codepoints) instead of the byte offset. -- cgit v1.2.3 From 4dbb6e3ff001bed14c64af3ddef87b3359a43505 Mon Sep 17 00:00:00 2001 From: Norman Clarke Date: Tue, 29 Jun 2010 23:25:17 -0300 Subject: Update Unicode database to 5.2.0. [#5011 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activesupport/lib/active_support/multibyte/unicode.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/multibyte') diff --git a/activesupport/lib/active_support/multibyte/unicode.rb b/activesupport/lib/active_support/multibyte/unicode.rb index f91e50c755..11c72d873b 100644 --- a/activesupport/lib/active_support/multibyte/unicode.rb +++ b/activesupport/lib/active_support/multibyte/unicode.rb @@ -9,7 +9,7 @@ module ActiveSupport NORMALIZATION_FORMS = [:c, :kc, :d, :kd] # The Unicode version that is supported by the implementation - UNICODE_VERSION = '5.1.0' + UNICODE_VERSION = '5.2.0' # The default normalization used for operations that require normalization. It can be set to any of the # normalizations in NORMALIZATION_FORMS. -- cgit v1.2.3 From 265b7c5edfe9b60d1ab547bfef569d94df05b8e9 Mon Sep 17 00:00:00 2001 From: Alex Muntean Date: Fri, 28 May 2010 13:22:29 +0900 Subject: Fix ActiveSupport::Multibyte::Chars#slice for empty strings when starting offset is negative [#4717 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activesupport/lib/active_support/multibyte/chars.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/multibyte') diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index 1134d1ccc6..9251b26f62 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -318,7 +318,8 @@ module ActiveSupport #:nodoc: character = Unicode.u_unpack(@wrapped_string)[args[0]] result = character.nil? ? nil : [character].pack('U') else - result = Unicode.u_unpack(@wrapped_string).slice(*args).pack('U*') + cps = Unicode.u_unpack(@wrapped_string).slice(*args) + result = cps.nil? ? nil : cps.pack('U*') end result.nil? ? nil : chars(result) end -- cgit v1.2.3 From 9ab8cfc21ab07b9a65388ce3643e5558642dbc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 30 Jun 2010 15:01:23 +0200 Subject: Improve the idiom used in multibyte chars a bit. --- activesupport/lib/active_support/multibyte/chars.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activesupport/lib/active_support/multibyte') diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index 9251b26f62..8823e4a5ed 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -316,12 +316,12 @@ module ActiveSupport #:nodoc: result = @wrapped_string.slice(*args) elsif args.size == 1 && args[0].kind_of?(Numeric) character = Unicode.u_unpack(@wrapped_string)[args[0]] - result = character.nil? ? nil : [character].pack('U') + result = character && [character].pack('U') else cps = Unicode.u_unpack(@wrapped_string).slice(*args) - result = cps.nil? ? nil : cps.pack('U*') + result = cps && cps.pack('U*') end - result.nil? ? nil : chars(result) + result && chars(result) end alias_method :[], :slice -- cgit v1.2.3