Ruby 1.9: force ascii encoding for comparison with utf8 regexp
This commit is contained in:
parent
278186534c
commit
bdaf3348de
|
@ -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 :
|
||||
|
|
Loading…
Reference in New Issue