Hi,
Some strange behind-the-scenes character conversion appears to be
occuring when fetching ASCII code 150 using ruby-odbc. This is
exempilfied by the script below. It should return identical data for
both selects. However, it does not. When char(150) is selected, the
ASCII character code 63 is returned. Not good.
Server information:
Linux version 2.6.12-10-686-smp (buildd@terranova) (gcc version 3.4.5
20050809 (prerelease) (Ubuntu 3.4.4-6ubuntu8)) #1 SMP Fri Nov 18
12:27:41 UTC 2005
ruby 1.8.3 (2005-06-23) [i486-linux]
What do yâall think?
Thanks,
Ben
=== script ===
require âodbcâ
connection=ODBC.connect(âdsnâ,âusernameâ,âpasswordâ)
sql1 = âselect char(150)â
puts âSelecting the ASCII character for char code 150 [#{sql1}]â
puts â=â * 70
results1 = connection.run(sql1)
results_array1 = results1.fetch_all
puts âCharacter: \tâ + results_array1[0][0]
print âChar Code: \tâ
print results_array1[0][0][0].to_i
puts
puts
sql2 = âselect ascii(char(150))â
puts âSelecting the numeric code for char(150) [#{sql2}]â
puts â=â * 70
results2 = connection.run(sql2)
results_array2 = results2.fetch_all
print âChar Code: \tâ
print results_array2[0][0]
puts
puts âCharacter: \tâ + results_array2[0][0].chr
=== Output ===
Selecting the ASCII character for char code 150 [select char(150)]
Character: ? <---- should be blank like the below
Char Code: 63 <---- should be 150
Selecting the numeric code for char(150) [select ascii(char(150))]
Char Code: 150
Character: (blank) <---- because the shell window wonât display
the em dash