title: String.encode() alternative in Ruby 1.8.7 for cleaning input to UTF-8
body: <p>I just discovered that the String.encode method is only available from Ruby -v 1.9.3 and upwards. I'm working in a Rails environment were I cannot change this. I used this method to correct invalid UTF-8 input.</p>
  
  <p>The only good alternative I've found was through the iconv.conv() method, however iconv is deprecated in newer ruby versions and I would like my code to be smelling like flowers even if/when my sysadmin decides to upgrade.</p>
  
  <p>For reference, the alternative I found from <a href="http://po-ru.com/diary/fixing-invalid-utf-8-in-ruby-revisited/" rel="nofollow">Here</a>:</p>
  
  <pre><code>ic = Iconv.new('UTF-8//IGNORE', 'UTF-8')
  valid_string = ic.iconv(untrusted_string + ' ')[0..-2]
  </code></pre>
  
  <p>Thanks!</p>