From: "Iñaki Baz Castillo" Date: 2009-09-02T07:37:49+09:00 Subject: Ruby1.9: Encoding problems (how to use #force_encoding ?) Hi, I'm using geo_location Ruby gem which returns to me a hash with the given IP geolocation. I use Ruby1.9 and UTF-8 works fine, but in this case, when the "city" has "strange" symbols the the gem gives the string encoded in ASCII-8BIT. For example: Alarc'n (theorically it should be "Alarcón") I need to send this string to a server which mandates UTF-8 usage so sending it as it's fails. I've tryed to convert the encoding but received an error: result.encode "UTF-8" => `encode': "\xF3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) I've also tryed with force_encoding: result.force_encoding "UTF-8" and then, the "result" string is converted to UTF-8 (I've checked result.encoding) but it's also not valid for the server and when printing it I see the same as before. I need all of this just for a simple demo, so it owuld be valid for me just to delete the non valid UTF-8 chars from the result string, but I don't know how to do it. Any help please? -- Iñaki Baz Castillo