I cannot seem to get the encoding right on my Oracle RoR combi. The information in the Oracle database seems to be encoded correctly. When looking up an attribute via SQL in need of special encoding I get eg 'Straße' which is what I expect. When requesting that same attribute from my RoR application I get 'Stra?e' which obviously is incorrect.
AMERICAN_AMERICA.AL32UTF8
utf8
AL16UTF16
I tried a couple of different things by changing the parameters above but nothing worked.
Anybody have a good idea?
将ENV['NLS_LANG'] ||= 'AMERICAN_AMERICA.UTF8'
到...\\config\\boot.rb
,它将适用于所有环境。
None of the solutions I could find on the web worked, but after reading the source of the ruby-oci8 gem, putting:
ENV['NLS_LANG'] = 'AMERICAN_AMERICA.AL32UTF8' DEFAULT_OCI8_ENCODING = 'utf-8'
in config\\boot.rb
worked for me.
有用的事情是降级我的oracle增强宝石
Just run before load app
OCI8.encoding=Encoding.default_internal
You can do too on put on first line on config/boot.rb
ENV['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'
This ensure that yours string will be in utf8 format when goes to database
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.