odbc
odbc copied to clipboard
Cannot read unicode from "PostgreSQL Unicode(x64)"
Steps to reproduce:
- Connect to some postgre database in windows using connection string with driver
PostgreSQL Unicode(x64)
. Optionally, specify the encoding to be UTF-8 in thedbConnect
argument. Example:
con <- DBI::dbConnect(odbc::odbc(),
.connection_string = "Driver={PostgreSQL Unicode(x64)`};Server=server;Port=5432;Database=db;
Uid=user;Pwd=pwd;",
encoding = "UTF-8")
- Retrieve data from some table (not from some self-sufficient statement like
select 'str'
) throughdbGetQuery
(from any package, e.g.DBI
,RPostgreSQL
,RPostgres
). Example:
df <- DBI::dbGetQuery(con, "select problem_col from some_table limit 10")
- Inspect said data in R.
Expected results: output data.frame
from dbGetQuery
should have the data as it is in the table, encoded in UTF-8.
Actual results: all the non-ascii characters get replaced with question marks, and the encoding from R's Encoding(char_vector)
is "unknown"
. Forcing it to some other encoding does not make a difference.
The problem is not present in linux with driver PostgreSQL UNICODE
(which is not accepted under windows).