[R] FW: R encoding question

Xiaobo Gu guxiaobo1982 at gmail.com
Wed Dec 1 06:26:22 CET 2010


It does not work,

> Sys.setlocale(locale = "Chinese_China")
[1] "LC_COLLATE=Chinese_People's Republic of
China.936;LC_CTYPE=Chinese_People's Republic of
China.936;LC_MONETARY=Chinese_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=Chinese_People's Republic of China.936"
> library(RpgSQL)
......
> driver <- pgSQL(classPath="D:/rtemp/postgresql-8.4-702.jdbc4.zip")
> con <- dbConnect(driver, dbname="demo", host="localhost", user="postgres", password="postgres", port=5432)
> df <- dbGetQuery(con, "select * from test")
> df
  a            b
1 1 椤惧皬娉\xa2
2 2   瑕冩€\xa1
>

On Tue, Nov 30, 2010 at 10:25 PM, Gabor Grothendieck
<ggrothendieck at gmail.com> wrote:
> On Tue, Nov 30, 2010 at 9:09 AM, Xiaobo Gu <guxiaobo1982 at gmail.com> wrote:
>> But locale "Chinese" will use GBK encoding by default, how to use UTF-8
>> encoding
>>
>> I have tried the following, neither of them works.
>>
>> Sys.setlocale(locale = "zh_CN.UTF-8")
>>
>> Sys.setlocale(category = "LC_CTYPE", locale= "zh_CN.UTF-8")
>>
>>
>
> Try this:
>
>> Sys.setlocale(locale = "Chinese_China")
> [1] "LC_COLLATE=Chinese (Simplified)_People's Republic of
> China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
> China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
> China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic
> of China.936"
>
> Although it does not specifically indicate UTF in the output if we now
> search for Chinese_China.936 we do find the link below which suggests
> that it is a UTF locale:
>
> http://docs.moodle.org/en/Table_of_locales
>
>
>
>
>
>
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
>



More information about the R-help mailing list