I'm running a ruby script on CentOS, and installed ruby via rvm (1.9.3).
I've set the NLS_LANG variable in .bash_profile.
[app@box stasis]$ echo $NLS_LANG
en_US.UTF-8
[app@box stasis]$ which ruby
~/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
However when trying to access it via ruby (which the oci8 driver does), it cannot find it:
1.9.3-p194 :001 > ENV['NLS_LANG']
=> nil
Accessing other vars seems to work:
1.9.3-p194 :004 > ENV['USER']
=> "app"
My script shows the following: Warning: NLS_LANG is not set. fallback to US7ASCII.
Thing is I'm running sqlplus from the ruby script (to execute some .sql files), and special characters are all messed up.
How can I get ruby to see the value?
You can view the NLS_LANG setting by entering the SELECT command: SELECT * FROM NLS_SESSION_PARAMETERS; The NLS_TERRITORY and NLS_LANGUAGE values correspond to the language and territory components of the NLS_LANG variable.
NLS_LANG is set as a local environment variable on UNIX platforms. NLS_LANG is set in the registry on Windows platforms. The NLS_LANG parameter has three components: language, territory, and character set. Specify it in the following format, including the punctuation: NLS_LANG = language_territory.charset.
You need to export your variables to be available in any applications run (unless they are functions):
export NLS_LANG
or together with setting:
export NLS_LANG=en_US.UTF-8
or as on most systems LANG
should be available:
export NLS_LANG=$LANG
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With