title: Ruby save file and encode it
body: <p>In my rails app i do file-upload, and some of my files are in russian (and other...). If i simply try:</p>
  
  <pre><code> require 'fileutils'
       uploaded_io = params[:aut]
       File.open(Rails.root.join('public', 'uploads_prices', uploaded_io.original_filename), 'w', :encoding =&gt; "r:UTF-8") do |file|
         file.write(uploaded_io.read)
       end
  </code></pre>
  
  <p>i get error</p>
  
  <p>also if i write</p>
  
  <pre><code>require 'fileutils'
      uploaded_io = params[:aut]
      File.open(Rails.root.join('public', 'uploads_prices', uploaded_io.original_filename), 'wb') do |file|
        file.write(uploaded_io.read)
      end
  </code></pre>
  
  <p>all is ok, but then, when i parse my csv-files, i need to decode them using option</p>
  
  <blockquote>
    <p>r:ISO-8859-15:UTF-8</p>
  </blockquote>
  
  <p>This is not good. So how could i do that if i send my file to method, it save it, but before it converts this file to utf8?</p>