Tuesday, August 21, 2012

Ruby 1.8.*, UTF-8 and Oracle / Oracle Enhanced / OCI-8

... is a mess.

For future reference:
  1. Check select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET'; is AMERICAN_AMERICA.AL32UTF8 or similar
  2. In your boot.rb, prior to any gems being loaded, add
    require 'rubygems'
    
    # Set up gems listed in the Gemfile.
    ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
    ENV['NLS_LANG'] = 'AMERICAN_AMERICA.AL32UTF8'
    
    require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
    
  3. Curse repeatedly at Oracle's database wide character sets, rather than MySQL's table based character sets - if you are migrating, you have to migrate every schema being used.
  4. Export your data, change the character set by ALTER DATABASE CHARACTER SET, re-import.

No comments: