odbc icon indicating copy to clipboard operation
odbc copied to clipboard

The Encoding of the column names is not UTF-8

Open shrektan opened this issue 4 years ago • 0 comments

Issue Description and Expected Result

When the SQL contains non-ASCII strings as the field names, the returned column names of the data.frame is not encoded as UTF-8.

Database

SQL Server 2014

Reproducible Example

Example:

library(odbc)
library(DBI)
con <- dbConnect(odbc::odbc(), dsn = "SQL Server")
x <- DBI::dbGetQuery(con, "select '汉语' as 中文")
Encoding(x[[1]]) # returns UTF-8
Encoding(colnames(x)) # returns unknown and are actually not UTF-8 encoded

image

shrektan avatar Jan 13 '21 06:01 shrektan