class ActiveRecord::ConnectionAdapters::MysqlAdapter

def client_encoding

Get the client encoding for this database
def client_encoding
  return @client_encoding if @client_encoding
  result = exec_query(
    "SHOW VARIABLES WHERE Variable_name = 'character_set_client'",
    'SCHEMA')
  @client_encoding = ENCODINGS[result.rows.last.last]
end