Skip to content

Roracle Chinese garbled on mac rstudio #9

@meteorwen

Description

@meteorwen

My operating system is mac os
Oracle Instant Client is already installed.
I am running under the R shell normally displaying Chinese characters.
However, Chinese characters displayed in rstudio are garbled. I see related problems in the centos environment<https://blog.csdn.net/xwydq/article/details/43734985>, but I can't solve the settings under mac OS.
The following are my environmental parameters:

/etc/profile:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
export ORACLE_HOME=/usr/local/oracle/instantclient_11_2
# export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$ORACLE_HOME/sdk/include
export CLASS_PATH=$JAVA_HOME/lib
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$ORACLE_HOME/sdk/include
export OCI_LIB=$ORACLE_HOME/sdk/include:$OCI_LIB
export LD_LIBRARY_PATH=$ORACLE_HOME/sdk/include
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_LANG=AMERICAN_AMERICA.UTF8

in mac os can not find filepath:

/usr/local/lib64/R/etc/   # Rprofile.site     Need to create the this file.
/etc/rstudio          # rserver.conf      Need to create the this file.

The questions are as follows:

>library(ROracle)
>library(magrittr)
>host <- "219.245.40.216"
>port <- 1521
>svc <- "ORCL"
>connect.string <- paste(
  "(DESCRIPTION=",
  "(ADDRESS=(PROTOCOL=tcp)(HOST=", host, ")(PORT=", port, "))",
  "(CONNECT_DATA=(SERVICE_NAME=", svc, ")))", sep = "")
>con <- dbConnect(drv=dbDriver("Oracle"),username="SWCJK",password="smt_swcjk",
                 dbname = connect.string)
>res <- dbSendQuery(con, "select * from SWCJK.ztsj_pks_list where rownum <= 10")
>fetch(res)


           XH  XM  SXY      NJ      MC              PKDF   JE
1  2140201080 ??? ????    ??44 ??????? -48.7453384399414 3500
2  2140201081 ??? ????    ??44 ???????  12.0239286422729 2500
3  2140201084  ?? ????    ??44 ???????              <NA> 3500
4  2140201087 ??? ????    ??44 ??????? -20.2788333892822 3500
5  2140202007 ??? ???? ?????41 ??????? -7.16327047348022 2500
6  2140202010  ?? ???? ?????41 ??????? -29.0816650390625 3500
7  2140202012  ?? ???? ?????41 ??????? -16.6532859802246 3500
8  2140202015  ?? ???? ?????41 ??????? -41.4543190002441 3500
9  2140202018  ?? ???? ?????41 ???????              <NA> 3500
10 2140301009 ??? ????    ??41   ?????              <NA>   NA

In the Mac OS environment, how to set up these 2 files to solve the problem of Chinese garbled? ?
(Running Chinese in the R shell is normal.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions