I have a rogue gem (omniauth) which provides a hash of data containing ASCII-BIT8 strings that I would like to convert into UTF.
How can I force all of the string elements of the hash into UTF, as some kind of rails initializer method? .to_utf8
initilizer
session[:omniauth] = omniauth.to_utf8
class Hash
def to_utf8
#not really sure what to do here?
end
end
In Ruby 1.9 you can usually just flip the encoding using the
encodemethod. A wrapper around this that recursively transforms the hash, not unlikesymbolize_keysmakes this straightforward: