New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
pedrogaspar opened this Issue May 17, 2013 · 3 comments

Comments

Projects
None yet
3 participants
@pedrogaspar

pedrogaspar commented May 17, 2013

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

This comment has been minimized.

Show comment
Hide comment
@chuckbergeron

chuckbergeron May 26, 2013

Contributor

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

Contributor

chuckbergeron commented May 26, 2013

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

This comment has been minimized.

Show comment
Hide comment
@senny

senny May 28, 2013

Member

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

Member

senny commented May 28, 2013

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

@senny

This comment has been minimized.

Show comment
Hide comment
@senny

senny Jul 12, 2013

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.

Member

senny commented Jul 12, 2013

@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