Permalink
Browse files

forcing encoding on 1.9 when dealing with "binary" columns [#4612 sta…

…te:resolved]

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
1 parent 6b49a71 commit eb69721c9bf2bd0f8957a231ecc91080b0645b84 @tenderlove tenderlove committed with wycats Jun 8, 2010
Showing with 4 additions and 0 deletions.
  1. +4 −0 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -34,6 +34,10 @@ def string_to_binary(value)
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"

0 comments on commit eb69721

Please sign in to comment.