aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/multibyte/chars.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-02-03 18:41:06 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2009-02-03 18:41:06 -0800
commitbdaf3348de0ea99525c685f9acfd7abb523f59c5 (patch)
treec4d1a09474f11ccc7b040aa42c6863d005b12390 /activesupport/lib/active_support/multibyte/chars.rb
parent278186534c0ccf285a20497461f40d2e54aa20a0 (diff)
downloadrails-bdaf3348de0ea99525c685f9acfd7abb523f59c5.tar.gz
rails-bdaf3348de0ea99525c685f9acfd7abb523f59c5.tar.bz2
rails-bdaf3348de0ea99525c685f9acfd7abb523f59c5.zip
Ruby 1.9: force ascii encoding for comparison with utf8 regexp
Diffstat (limited to 'activesupport/lib/active_support/multibyte/chars.rb')
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb2
1 files changed, 2 insertions, 0 deletions
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 :