I'm experimenting a bit with libmdbodbc and ruby-odbc to access datas on an Access MDB file, whenever I access a Text field, and print to the screen the results, I can see at the end of the string some printable and/or unprintable characters (always two of them).

Here id my odbcinst.ini:

Description = MDB Tools ODBC drivers
Driver = /usr/lib/libmdbodbc.so.0
Setup =
FileUsage = 1
CPTimeout =
CPReuse =
DisableGetFunctions = 0
UsageCount = 1

Trace = yes
TraceFile = /var/tmp/odbc.log

and my odbc.ini:

Description = Demo
Driver = MDBToolsODBC
Database = /home/me/Documenti/Programmazione/demo.mdb
Servername = localhost
UserName =
Password =

This could be an example usage:

require "odbc"
connection = ODBC.connect "Demo"
query = connection.prepare("SELECT NAME FROM USERS")
query.execute.each_hash() { |row| print "#{row["NAME"].inspect}\n" }

This prints to the screen something like:

Sample Name�M
Another Sample Name��
Third sample name��

What I was expecting is:

Sample Name
Another Sample Name
Third sample name

Without the trailing strange chars.

Looking at the trace (after having asked to the ruby-odbc developer that kindly pointed me to the log saying that it's library, relying on the infos found thanks to your driver (the SQLGetData function), uses a StrLen of 2 chars longer that the actual string size, because the function reports the wrong length, here is an excerpt of the LOG file:

                        Buffer = [Sample Name]               
                        Strlen Or Ind = 0x7fff0b22ece0 -> 13

But "Strlen Or Ind" should be 11.
How could I get rid of those unwanted chars (without having to deal with String functions in ruby, it's always a viable solution, but if this bug will be resolved, that code will become useless)

Thank you for the answer.