title: Invalid multibyte char with Ruby 1.9, setting encoding: utf-8 does not fix it
body: <p>I just upgraded my Ruby version from 1.8.7 to 1.9.2 (using RVM). So Ruby is: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0]. The app is on Rails 3.2.8. Since upgrading, I get an error regarding multi-byte characters. </p>
  
  <p>I've found multiple <em>very similar</em> issues on stackoverflow, but none of the solutions in them worked for me:</p>
  
  <p><a href="https://stackoverflow.com/questions/3678172/ruby-1-9-invalid-multibyte-char-us-ascii">Ruby 1.9 - invalid multibyte char (US-ASCII)</a>
  and
  <a href="https://stackoverflow.com/questions/1739836/invalid-multibyte-char-us-ascii-with-rails-and-ruby-1-9">invalid multibyte char (US-ASCII) with Rails and Ruby 1.9</a> 
  and
  <a href="https://stackoverflow.com/questions/6774080/rails-3-1-ruby-1-9-2-p180-and-utf-8-issues">Rails 3.1, Ruby 1.9.2-p180 and UTF-8 issues</a></p>
  
  <p>When I start my app, and try to browse to it, I multiple errors, such as:</p>
  
  <blockquote>
    <p>SyntaxError
    (/Users/antun/ror/parktwor3svn/app/helpers/application_helper.rb:35:
    invalid multibyte char (UTF-8)
    /Users/antun/ror/parktwor3svn/app/helpers/application_helper.rb:35:
    syntax error, unexpected tIDENTIFIER, expecting ']' ... States",
    "Afghanistan", "?land Islands", "Albania", "Algeri...</p>
  </blockquote>
  
  <p>The offending code (in app/helpers/application_helper.rb) looks like this. For brevity, I've boiled it down to just the first few countries - the "Å" in "Åland Islands" is one of the characters that triggers it. When I look up that character in my editor, I get: 00c5. (There's a bunch more unicode characters in other country names). </p>
  
  <pre><code>  def countries
      return ["", "United States", "Afghanistan", "Åland Islands", "Albania"]
    end
  </code></pre>
  
  <p>So far, I have tried adding the following to app/helpers/application_helper.rb <em>as the very first line</em> to fix it:</p>
  
  <pre><code># encoding: UTF-8
  </code></pre>
  
  <p>and</p>
  
  <pre><code># encoding: utf-8
  </code></pre>
  
  <p>and</p>
  
  <pre><code># -*- coding: utf-8 -*-
  </code></pre>
  
  <p>None of these worked.</p>
  
  <p>My config/application.rb has:</p>
  
  <pre><code>config.encoding = "utf-8"
  </code></pre>
  
  <p>My text editor is VIM, and when I do :set encoding on that file, it returns: "encoding=utf-8".</p>