title: gsub codification issues with UTF-8
body: <p>I am trying to create a slug from some usernames in a DB migration.</p>
  <pre><code>nick = nick.gsub('á','a')
  </code></pre>
  <p>I really want change also <code>éíóúñ</code> to <code>eioun</code>.</p>
  <p>Doing so, it doesn't work, I will get:</p>
  <blockquote>
  <p>incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)</p>
  </blockquote>
  <p>But, however I do, for example by adding force_encoding method, I always get encodings errors like:</p>
  <blockquote>
  <p>invalid byte sequence in UTF-8 (ArgumentError)</p>
  <p>&quot;\xF3&quot; from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)</p>
  <p>incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)</p>
  </blockquote>
  <p>This just happends when I have a gsub for changing those vocals or the spanish ñ letter.</p>
  <p>There's also a <code>encoding: utf-8</code> line on my file and data comes from a UTF-8 database. But nothing seems to help.</p>
  <p>I've seen some questions on SO but anything I try to do doesn't fix it.</p>
  <p>By the way, this is not rails related.</p>