This seems to work for me:
"Hern\xE1ndez".encode('UTF-8','ISO-8859-1')
The first argument is the encoding that you want the string to be in and the second argument is the encoding that you think the string is in.
String#encode
There are also options in the documentation on how to deal with invalid or undefined characters.
This is what I ended up using (just to be safe):
"Hern\xE1ndez".encode('UTF-8','ISO-8859-1', :invalid => :replace, :undef => :replace, :replace => "?")
You can also make up a helper method:
def convert_to_utf_8(string)
string.encode('UTF-8','ISO-8859-1', :invalid => :replace, :undef => :replace, :replace => "?")
end
The problem I was having was loading data from the Amazon Merchant Services API.