after "gem install ruby-odbc" there are four libraries:
c:\Ruby19\lib\ruby\gems\1.9.1\gems\ruby-odbc-0.99991\ext\odbc.so
c:\Ruby19\lib\ruby\gems\1.9.1\gems\ruby-odbc-0.99991\ext
\utf8\odbc_utf8.so
c:\Ruby19\lib\ruby\gems\1.9.1\gems\ruby-odbc-0.99991\lib\odbc.so
c:\Ruby19\lib\ruby\gems\1.9.1\gems\ruby-odbc-0.99991\lib\odbc_utf8.so
and Christan tells us in his README:
Thus, depending on the -K option of ruby one could use
that code snippet:
...
if $KCODE == "UTF8" then
require 'odbc_utf8'
else
require 'odbc'
fi
But in sqlserver_adapter.rb i can only find a line:
require_library_or_gem 'odbc' unless defined?(ODBC)
So I inserted a require "odbc_utf8" in environment.rb,
now for column names
column_names.each do { |col| puts col.encoding }
it tells me that all column_names are still ASCII-8BIT
but the names are OK on the web page.
but or the data itself:
for columns declared as varchar() it tells me that the encoding is
ASCII-8BIT
and the data is OK on the web page
for columns declared as nvarchar() it tells me that the encoding is
UTF-8
but the data fails to display with error "incompatible character
encodings: ASCII-8BIT and UTF-8"
if I start Ruby with Ruby -Eutf-8 this will reverse the effect
varchar() now fails with the error and nvarchar shows up ok.
( All Tests were running on Windows XP, ruby 1.9.1p378 [i386-mingw32],
Rails 2.3.5, ruby-odbc 0.99991
using Microsoft SQL Server Native Client 9.00.4035.00 against an SQL
Server 2005 on Windows Server 2003 )
I will get some help from a Ruby professional tomorrow and we will try
to setup a test environment.
Should I test against the new 2.3.6 release ??? ( or 2.3.5 or both ? )
Currently I only have a SQL Server 2005 installed and I don't know if
I will have enough time for also installing and testing SQL Server
2000 and 2008, sry for that.
I am just reading the Microsoft documentation on SQL Server and found
that for all SQL Server releases 2000/2005/2008 the table names and
column names are allowed as unicode strings. I will try to tackle this
tomorrow.
Greetings
Klaus
> >> For more options, visit this group athttp://groups.google.com/group/rails-sqlserver-adapter?hl=en.
On a side note, I just found out that you can have method names in ruby as unicode strings, which makes sense, but I never tried. I mention it because if that was not the case, then those column names would not come down to real method names for an AR object.
- Ken