How to deal with "incompatible character encodings: ASCII-8BIT and GBK exception"?

I am reading Agile Web Development with Rails.3rd. When I finish the depot application, I enter some kind of Chinese character as the username. But I got this error, it seems to be related to Ruby1.9.

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

The following is the details of this error:


Application mapping /views/layouts/store.html.erb, where line # 43 is raised:

incompatible character encodings: ASCII-8BIT and GBK

Extracted source (around line # 43):

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

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

42: <% end -%>

43: <% = output: layout%>


Can anyone help me solve this problem?

+3
3

,

# encoding: utf-8

(, , )

+2

environment.rb:

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

​​Windows. , Unicode.

0

, ,

, "C" name%)

, , , - c, a, o, p .. .

0

Source: https://habr.com/ru/post/1756492/


All Articles