错误:不兼容的字符编码:UTF-8和ASCII-8BIT
问题描述:
当视图在数据库中发现一些字符,如ñ,á,é等时,我得到了错误incompatible character encodings: UTF-8 and ASCII-8BIT
.
I got the error incompatible character encodings: UTF-8 and ASCII-8BIT
, when the view found in the database some characters like: ñ, á, é, etc.
我的环境是:
- 路轨:3.2.5
- Ruby:1.9.4p194
- 数据库:Oracle 10g(10.2.0.1.0)
我可以使用Toad将这些字符保存在数据库中.
I can save this characters in the database, using Toad.
我试图在我的观点的第一行中写这个:
I tried to write this, in the first line of my view:
<% # encoding: utf-8 %>
在enviroment.erb
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
但是没有什么可以解决的.
But nothing fixed this.
请,有人可以提供一些建议来解决此问题.
Please, can someone give some adviced to fixed this.
谢谢.
答
在文件boot.rb
中,我添加了以下行:
In the file boot.rb
, I added this line:
ENV['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'
这个我解决了我的问题.
Whit this I solved my problem.