Method: ActiveRecord::ConnectionAdapters::SQLiteColumn.binary_to_string

Defined in:
lib/active_record/connection_adapters/sqlite_adapter.rb

.binary_to_string(value) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_record/connection_adapters/sqlite_adapter.rb', line 17

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"
      when "%25" then "%"
    end
  end
end