David wrote:
> I have no idea why this is happenning.
> Although I can convert it to UTF-8 by doing
> params[:name].force_encoding('UTF-8'), this isn't a pretty solution.
> There should be some way of fixing this or I am missing something.
> I googled for the last two days, but haven't got any solution.
> 
> Have anyone had the similar problem?
> Your help will be very much appreciated.

Nathan is on the money here. Although the submitted data is almost
certainly UTF-8, rails 2.3.* and rack 1.0.* don't handle encodings in a
ruby 1.9 sane way, so the string is marked with the default "oh god I
don't know what encoding this string is" - ASCII-8BIT.

You can get around it with various monkey patches and before filters
like you suggest, but it gets messy fast. Chances are your database
driver will also be returning strings with an incorrect encoding, so
even if you fix the incoming params, you'll have to sort out all your
string model attributes too.

imho your best bet is to downgrade to ruby 1.8.7 until rails 3 is
released. I haven't tested it, but it apparently has significantly better
encoding support.

-- James Healy <[email protected]>  Tue, 02 Mar 2010 14:41:08 +1100

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" 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/rails-oceania?hl=en.

Reply via email to