Per the documentation, you can probably do something like this:

file = params[:file]
CSV.open(file.tempfile, "rb:UTF-32BE:UTF-8", {:headers => false, :col_sep =>
";"}) do |row|
  @newhash << {:var1 => row[0], :var2 => row[1]}
end

Replace "UTF-32BE" with your incoming encoding and "UTF-8" with the encoding
you want to parse/store your data in.



On Wed, Jun 22, 2011 at 12:11 PM, Sebastian
<[email protected]>wrote:

> Hi Chirag,
>
> thank you for the links. I will read them and look if there is
> something that can help me.
>
> I found out that the main problem was that my gvim editor saved every
> *.rb file not in utf-8 encoding. I just edited them with notepad and
> saved them explicitly in utf-8 and then the german special characters
> worked in my controllers.
>
> There is still the problem with the CSV class, which I need to import
> a csv file. This class is not able to read the special characters.
>
> I found the documentation here:
> http://www.ruby-doc.org/ruby-1.9/classes/CSV.html#M001340
>
> there is something about encodings, but I don't understand how to use
> it!!!
>
>
> Sebastian
>
> On 21 Jun., 14:34, Chirag Singhal <[email protected]> wrote:
> > Hi Sebastian,
> >
> > I personally haven't had to deal with encoding issues yet, but remember
> > reading couple of posts from Yehuda Katz (of merb fame and core
> contributor
> > to rails) on that.
> > Maybe these can help you identify and fix your problem:
> http://yehudakatz.com/2010/05/17/encodings-unabridged/http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-.
> ..
> >
> > The articles are little long, but if you know a good deal about
> encodings,
> > then you can skip towards end of the posts where he writes about how to
> deal
> > with conversions.
>
> --
> 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.
>
>


-- 
Chirag
http://sumeruonrails.com

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

Reply via email to