Bad encoding when presenting the lines of a posted text file #10668

pedrogaspar opened this Issue May 17, 2013 · 3 comments

3 participants


Having a form that submits a file, when reading with:

file = params[:file]
@file =

and presenting in a view

<%= @file %>

Shows the error: incompatible character encodings: ASCII-8BIT and UTF-8

But if we read with

file =[:file].path)

It works.


Just tested it out with Rails 4.1.0beta & Ruby 2.0.0-p0, and it worked slick for me.

Pre-Ruby2 is a bit messy when it comes to encodings. Sometimes you need to explicitly state which encoding you want to open the file with (which is less than ideal).

Ruby on Rails member

@pedrogaspar can you post an isolated sample application that shows the problem and upload it to github?

Ruby on Rails member

@pedrogaspar It's been a month since we heard from you. Without further debugging information it's hard to track the issue down. I'm closing this one but please report back if you still experience this problem.

Thanks for reporting.

@senny senny closed this Jul 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment