title: Delete non-UTF characters from a string in Ruby?
body: <p>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 UTF8.</p>
  
  <p>This:</p>
  
  <pre><code>text.gsub!(/\xC2/, '')
  </code></pre>
  
  <p>returns an error: </p>
  
  <pre><code>incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)
  </code></pre>
  
  <p>I was looking at text.unpack('U*') and string.pack as well, but did not get anywhere.</p>