forcing encoding on 1.9 when dealing with "binary" columns [#4612 state:resolved]

Signed-off-by: wycats <wycats@gmail.com>
This commit is contained in:
Aaron Patterson
2010-06-08 10:25:41 -04:00
committed by wycats
parent 6b49a71ab7
commit eb69721c9b

View File

@@ -34,6 +34,10 @@ module ActiveRecord
end
def binary_to_string(value)
if value.respond_to?(:force_encoding) && value.encoding != Encoding::ASCII_8BIT
value = value.force_encoding(Encoding::ASCII_8BIT)
end
value.gsub(/%00|%25/n) do |b|
case b
when "%00" then "\0"