Tôi đã nâng cấp lên RoR 3.0.1 và Ruby thành 1.9.2. Bây giờ tất cả các chuỗi trong quan điểm của tôi là ASCII-8BIT?Tại sao tất cả các chuỗi ASCII-8BIT sau khi tôi nâng cấp lên Rails 3?
Tôi tin rằng tôi đã ứng dụng của tôi thiết lập để sử dụng UTF 8
application.rb
config.encoding = "utf-8"
database.yml
development:
adapter: mysql
encoding: utf8
Tôi đang chạy
OS X
RVM rvm 1.0.16
Ruby ruby-1.9.2-p0
Rails 3.0.1
tôi mong đợi rằng enoding sẽ là UTF 8 không ASCII
business.desc.encoding
# ASCII-8BIT
Kể từ 1.9.x có thể nối chuỗi mã hóa khác nhau chúng ta thấy rất nhiều lỗi như thế này.
<p class="description"><%= truncate(business.desc, :length => 17) %></p>
Các Lỗi
incompatible character encodings: ASCII-8BIT and UTF-8
activesupport (3.0.1) lib/active_support/core_ext/string/output_safety.rb:74:in `concat'
activesupport (3.0.1) lib/active_support/core_ext/string/output_safety.rb:74:in `concat'
actionpack (3.0.1) lib/action_view/template/handlers/erb.rb:14:in `<<'
app/views/browse/businesses.html.erb:15:in `block in _app_views_browse_businesses_html_erb___1616718260917998189_2173630500__1134905695726531092'
app/views/browse/businesses.html.erb:3:in `each'
app/views/browse/businesses.html.erb:3:in `each_with_index'
app/views/browse/businesses.html.erb:3:in `_app_views_browse_businesses_html_erb___1616718260917998189_2173630500__1134905695726531092'
Có ai khác có vấn đề này? Có phải ruby-1.9.2-p0 là phiên bản chính xác để sử dụng không?
Cảm ơn!
Cơ sở dữ liệu của bạn thực sự nằm trong utf-8, vì bảng mã arg không xác định mã hóa cơ sở dữ liệu. Bạn có thể có một cơ sở dữ liệu trong mã hóa khác – shingara