Permalink
Browse files

Ruby 1.9: force ascii encoding for comparison with utf8 regexp

  • Loading branch information...
jeremy committed Feb 4, 2009
1 parent 2781865 commit bdaf3348de0ea99525c685f9acfd7abb523f59c5
Showing with 2 additions and 0 deletions.
  1. +2 −0 activesupport/lib/active_support/multibyte/chars.rb
@@ -617,6 +617,8 @@ def compose_codepoints(codepoints)
# 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 :

0 comments on commit bdaf334

Please sign in to comment.