From eb69721c9bf2bd0f8957a231ecc91080b0645b84 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 8 Jun 2010 10:25:41 -0400 Subject: forcing encoding on 1.9 when dealing with "binary" columns [#4612 state:resolved] Signed-off-by: wycats --- activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index e8a45bb3c6..deb62e3802 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -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" -- cgit v1.2.3