Skip to content

Instantly share code, notes, and snippets.

@jamesgolick
Forked from lsegal/mysql_utf8.rb
Created November 7, 2009 01:43
Show Gist options
  • Save jamesgolick/228456 to your computer and use it in GitHub Desktop.
Save jamesgolick/228456 to your computer and use it in GitHub Desktop.
class Mysql::Result
def each_utf8(&block)
each_orig do |row|
yield row.map {|col| String === col ? col.force_encoding("utf-8") : col }
end
end
alias each_orig each
alias each each_utf8
def each_hash_utf8(&block)
each_hash_orig do |row|
row.each do |k, v|
row[k] = String === v ? v.force_encoding("utf-8") : v
end
yield(row)
end
end
alias each_hash_orig each_hash
alias each_hash each_hash_utf8
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment