ROracle encoding issues

ぐ巨炮叔叔 提交于 2019-12-11 16:07:23

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/46807009/roracle-encoding-issues

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!