views:

98

answers:

1

I am reading 'Agile Web Development with Rails.3rd'. When finishing the depot application, I input some Chinese character as user name. But I got this error, it seems this has something to do with Ruby1.9

My environment is window xp, Ruby1.9 Rails 2.3.8 and sqlite3.

The following is the detail about this error:


Showing app/views/layouts/store.html.erb where line #43 raised:

incompatible character encodings: ASCII-8BIT and GBK

Extracted source (around line #43):

40: <% if flash[:notice] -%>

41: <%=h flash[:notice] %>

42: <% end -%>

43: <%= yield :layout %>


Anyone can help me resolve this problem ?

A: 

You might try putting this in your environment.rb file:

Encoding.default_internal = Encoding.find("UTF-8")

You might also be compounding the problem with incorrect console encoding in Windows. Make sure it is set to Unicode.

Preston Marshall
It's seems like this does work. I got nil error when I add Encoding.default_internal = Encoding.find("UTF-8") in my environment.rb file.
Chris
You mean it doesn't work? If it does, give me a check ;)
Preston Marshall
It doesn't work. I got this error"Internal Server ErrorYou have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each "
Chris
Error during failsafe response: "\xE6" from ASCII-8BIT to UTF-8 in conversion from ASCII-8BIT to GBK
Chris