From bdaf3348de0ea99525c685f9acfd7abb523f59c5 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Tue, 3 Feb 2009 18:41:06 -0800 Subject: Ruby 1.9: force ascii encoding for comparison with utf8 regexp --- activesupport/lib/active_support/multibyte/chars.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/lib/active_support/multibyte/chars.rb') diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index a00b165222..62b6d798ef 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -617,6 +617,8 @@ module ActiveSupport #:nodoc: # Replaces all ISO-8859-1 or CP1252 characters by their UTF-8 equivalent resulting in a valid UTF-8 string. def tidy_bytes(string) string.split(//u).map do |c| + c.force_encoding(Encoding::ASCII) if c.respond_to?(:force_encoding) + if !UTF8_PAT.match(c) n = c.unpack('C')[0] n < 128 ? n.chr : -- cgit v1.2.3