title: Encoding Ruby - different behaviour on two machines
body: <p>I am trying to run a ruby script that uses inside a function that removes diacritics:</p>
  
  <pre><code>def remove_diacritics(text)
  return text.tr!(
  "ÀÁÂÃÄÅàáâãäåĀāĂăĄąÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňŉŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž",
  "AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz")
  end
  </code></pre>
  
  <p>I have the magic <code># encoding: utf-8</code> at the beginning and I am getting some strange behaviour. It works on Mac but when I copy exactly the same file to Raspberry Pi, I am getting this error:</p>
  
  <blockquote>
    <p>remove_diacritics.rb:28:in `tr!': incompatible character encodings: US-ASCII and UTF-8 (Encoding::CompatibilityError)</p>
  </blockquote>
  
  <p>This seems to be a classic in help forums. The mesmerising thing is that it does work on one machine and doesn't on the other one, even though the versions of Ruby are exactly the same, ruby 1.9.3p286 (2012-10-12 revision 37165).</p>
  
  <p>Any suggestions?</p>