B
Ben
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
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