ruby-odbc icon indicating copy to clipboard operation
ruby-odbc copied to clipboard

Database.get_info returns malformed ASCII in UTF8 mode

Open bwarminski opened this issue 6 years ago • 3 comments
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

bwarminski avatar Jan 17 '19 18:01 bwarminski

Fwiw, this was tested on two 64-bit systems - OSX and Ubuntu 14.

bwarminski avatar Jan 17 '19 18:01 bwarminski

@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/

larskanis avatar Jan 18 '19 11:01 larskanis

+1

gregorw avatar Sep 17 '21 12:09 gregorw