ROracle encoding issues

2019-08-17 00:05发布

I am using the ROracle library to access an Oracle database from RStudio. Please see the code below:

drv = dbDriver("Oracle")
connect.string = paste(
  "(DESCRIPTION=",
  "(ADDRESS=(PROTOCOL=tcp)(HOST=", host, ")(PORT=", port, "))",
  "(CONNECT_DATA=(SID=", sid, ")))", sep = "")

con = dbConnect(drv, username = "",
                 password = "",dbname=connect.string, encoding="latin1")

### Pull tables
keyword = dbGetQuery(con, "select COLUMN1,COLUMN2 from TABLE1")

In my column i got the words: Lørdag, søndag etc which is returned as: L?rdag, S?ndag.

R Session Info:

R version 3.4.2 (2017-09-28) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252

attached base packages: [1] parallel stats graphics grDevices utils datasets methods base

other attached packages: [1] stringi_1.1.5 doParallel_1.0.11 iterators_1.0.8 ROracle_1.3-1 DBI_0.7 foreach_1.4.3

loaded via a namespace (and not attached): [1] compiler_3.4.2 tools_3.4.2 codetools_0.2-15

标签: roracle
1条回答
狗以群分
2楼-- · 2019-08-17 00:21

Finally works! Apparently i couldnt find any way to force encoding in my code. However, i added the environment variable "NLS_LANG" and the corresponding langauge code to my operating system which fixed the issue

查看更多
登录 后发表回答