ruby-odbc
ruby-odbc copied to clipboard
Database.get_info returns malformed ASCII in UTF8 mode
trafficstars
To reproduce:
require 'odbc_utf8'
attrs = 'DRIVER={PostgreSQL ANSI};SERVER=localhost;PORT=5432;DATABASE=odbc_test;UID=postgres;ENCODING=utf8'.split(';').map { |option| option.split('=', 2) }.to_h
driver = ODBC::Driver.new
driver.name = 'odbc'
driver.attrs = attrs
conn = ODBC::Database.new.drvconnect(driver)
i = conn.get_info(ODBC::SQL_DBMS_NAME)
puts i.encoding
Regardless of LOCALE, LC_CODE, LC_ALL the value returned is always ASCII-8BIT and the string appears to be UTF-16 Little endian coded, a la P\x00o\x00s\x00t\x00g\x00r\x00e\x00S\x00Q\x00L\x00
Fwiw, this was tested on two 64-bit systems - OSX and Ubuntu 14.
@bwarminski Thanks for reporting this issue!
However I don't maintain this gem, but fortunately Christian Werner does. Please send him an email about this issue. See http://www.ch-werner.de/rubyodbc/
+1