[Rails] Re: Problem with special characters and CSV upload
It is not only the CSV upload!
If I just add the following to my controller:
# encoding: utf-8
class HomeController < ApplicationController
def index
@u = "Müsli"
end
end
Error still remains: "invalid byte sequence in UTF-8"
I don't understand that because it says that it is already in
"UTF-8"...
If I just use a special character in a view it is working, e.g. <%=
"Müsli"%>
I read something about that gvim editor saves files in latin encoding
for default. Could that be related to my issue???
Cheers,
Sebastian
On 20 Jun., 11:46, Sebastian <sebastian.go...@googlemail.com> wrote:
> Hi,
>
> I am using the following code to upload a CSV and store it into my
> sqlite db:
>
> file = params[:file]
> temp = CSV.new(file.tempfile, {:headers => false, :col_sep => ";"})
>
> temp.each do |row|
> @newhash << {:var1 => row[0], :var2 => row[1]}
> end
>
> Finally I create a new record out of the @newhash above, but I got an
> error before, when I have a special character in the row:
> "invalid byte sequence in UTF-8"
>
> I have german special characters: ä, ö, ü
>
> Without these characters, my code is working!!!!
>
> How can avoid the error by using the right encoding?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home