Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
pedrogaspar opened this Issue · 3 comments

3 participants

@pedrogaspar

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

file = params[:file]
@file = file.read

and presenting in a view

<%= @file %>

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

But if we read with

file = File.read(params[:file].path)

It works.

@chuckbergeron

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).

@senny
Owner

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

@senny
Owner

@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.