Take the 2-minute tour ×

I received the following error upon saving a new contact. Is there a way to cast "\xC2" so that it can be forced to be saved in the UTF-8 format?

c = Contact.new

Encoding::UndefinedConversionError: "\xC2" from ASCII-8BIT to UTF-8: INSERT INTO "contacts" ("body", "created_at", "email", "updated_at") VALUES (?, ?, ?, ?)

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Your string is in some other encoding, most likely iso-8859-1, so you should run this to convert it:

=> "Ã"

See this question for more information related to this issue.

share|improve this answer
Was flailing around converting some code that used HtmlEntities from 1.8.7 to 1.9.3 — This helped. Thanks! –  Subimage Dec 28 '13 at 9:28
add comment

Your Answer


