Update: If I use in my controller: #encoding: CP850 or #encoding: iso-8859-1 then the error message didn't appear, but the special character ü is replaced by a question mark.
Looks like this: M�sli I thought utf-8 is able to handle german special characters. It took me the whole day and I still didn't come to a solution. I really hope that someone can help me. Cheers, Sebastian On 21 Jun., 14:12, Sebastian <[email protected]> wrote: > 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 <[email protected]> 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

