Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ruby 1.9: force ascii encoding for comparison with utf8 regexp

  • Loading branch information...
commit bdaf3348de0ea99525c685f9acfd7abb523f59c5 1 parent 2781865
@jeremy jeremy authored
Showing with 2 additions and 0 deletions.
  1. +2 −0  activesupport/lib/active_support/multibyte/chars.rb
View
2  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 :
Please sign in to comment.
Something went wrong with that request. Please try again.