# Oracle legacy database with ISO-8859-1

**URL:** <https://www.ruby-forum.com/t/oracle-legacy-database-with-iso-8859-1/121390>\
**Category:** Rails\
**Created:** [November 27, 2007, 4:03pm UTC](https://www.ruby-forum.com/t/oracle-legacy-database-with-iso-8859-1/121390 "2007-11-27T16:03:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 27, 2007, 4:03pm UTC](https://www.ruby-forum.com/t/oracle-legacy-database-with-iso-8859-1/121390/1 "2007-11-27T16:03:02Z")

</div>

Hi,

I ve got a legacy oracle database in ISO-8859-1 encoding, which is in  
use by other applications as well.

Now, I would like to add a rails app for new features. Rails is using  
unicode so special characters are stored incorrectly in the database.

Does anybody know how I might fix that. I ve already told my  
controllers to use that charset, but my models still store these  
values as utf8 and that goes directly into the database. ☹

Converting the whole database to unicode is not an option due to the  
other legacy apps.

Hope anybody can help me.

thanks a lot in advance.

–  
Volker

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 27, 2007, 4:51pm UTC](https://www.ruby-forum.com/t/oracle-legacy-database-with-iso-8859-1/121390/2 "2007-11-27T16:51:11Z")

</div>

hello, you should change kcode in your environment.rb : $KCODE =  
‘NONE’ to specify ruby interpreter you don’t use utf-8. and check  
“encoding” parameter in database.yml.

On Nov 27, 4:02 pm, “removed\_email\_address@domain.invalid”

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 28, 2007, 8:54am UTC](https://www.ruby-forum.com/t/oracle-legacy-database-with-iso-8859-1/121390/3 "2007-11-28T08:54:21Z")

</div>

Please do post back to tell us if Jean-Sebestien’s suggestions work. If  
not,  
for my non-rails apps, I set the NLS\_LANG variable in the environment to  
the  
character set of the database before starting the web server. This might  
or  
might not help.

–  
Cynthia K.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 28, 2007, 9:25am UTC](https://www.ruby-forum.com/t/oracle-legacy-database-with-iso-8859-1/121390/4 "2007-11-28T09:25:56Z")

</div>

Hi,

Unfortuently, setting the KCODE to NONE did not fix my problem. The  
strings are still stored with unicode settings in my database.  
I ve set the encoding in database.yml, however, so far I ve read  
nowhere that the oci adapter supports that argument.

Im not sure if I understood that NLS\_LANG suggestion… However, I can  
assure you that I have no control at all over the other systems… ☹

Anyone else with an idea… Maybe somebody knows about a plugin which  
converts between charsets during write/read operations to the  
database???

–  
Volker

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 28, 2007, 10:04am UTC](https://www.ruby-forum.com/t/oracle-legacy-database-with-iso-8859-1/121390/5 "2007-11-28T10:04:37Z")

</div>

sorry, i thought it could work with it (it does with postgres and  
mysql). i just find an article about using oracle with rails, i hope  
it could help you:  
[http://blog.zmok.net/articles/2007/05/07/ruby-on-rails-with-oracle](http://blog.zmok.net/articles/2007/05/07/ruby-on-rails-with-oracle)

On Nov 28, 9:25 am, “removed\_email\_address@domain.invalid”

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 28, 2007, 2:20pm UTC](https://www.ruby-forum.com/t/oracle-legacy-database-with-iso-8859-1/121390/6 "2007-11-28T14:20:42Z")

</div>

Great,

setting ENV[‘NLS\_LANG’]=‘GERMAN\_GERMANY.UTF8’ in my environment file  
fixed my issues.

Thanks a lot.

–  
Volker
