How do I delete non-UTF8 characters from a ruby string? I have a string that has for example \"xC2\" in it. I want to remove that char from the string so that it becomes a valid
You can use encode for that. text.encode('UTF-8', :invalid => :replace, :undef => :replace)
text.encode('UTF-8', :invalid => :replace, :undef => :replace)
For more info look into Ruby-Docs