ROracle编码问题 [英] ROracle encoding issues

查看:83
本文介绍了ROracle编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ROracle库从RStudio访问Oracle数据库.请参见下面的代码:

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")

在我的专栏中,我得到了这样的文字:Lørdag,søndag等,其返回形式为:L?rdag,S?ndag.

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

R会话信息:

R版本3.4.2(2017-09-28) 平台:x86_64-w64-mingw32/x64(64位) 在以下环境下运行:Windows> = 8 x64(内部版本9200)

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

Matrix产品:默认

Matrix products: default

语言环境: [1] LC_COLLATE =英语_美国.1252 LC_CTYPE =英语_美国.1252 LC_MONETARY =英语_美国.1252 [4] LC_NUMERIC = C LC_TIME = English_United States.1252

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

附带的基本软件包: [1]并行统计图形grDevices utils数据集方法基础

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

其他附带的软件包: [1] stringi_1.1.5 doParallel_1.0.11 iterators_1.0.8 ROracle_1.3-1 DBI_0.7 foreach_1.4.3

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

通过名称空间(未附加)加载: [1]编译器_3.4.2工具_3.4.2代码工具_0.2-15

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

推荐答案

终于可以了!显然我找不到在我的代码中强制编码的任何方法.但是,我在操作系统中添加了环境变量"NLS_LANG"和相应的语言代码,从而解决了该问题

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

这篇关于ROracle编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆