[R-sig-DB] MySQL R Encoding Utf8

Henri Mone henriMone at gmail.com
Thu Feb 9 11:10:59 CET 2012


Dear Nishiyama,

Thank you very much for your fast help. I worked out of the the box
like a charm :) .

Thanks,
Henri

On Thu, Feb 9, 2012 at 1:17 AM, NISHIYAMA Tomoaki
<tomoakin at staff.kanazawa-u.ac.jp> wrote:
> Hi,
>
> dbGetQuery(t.con, "SET NAMES 'utf8'")
> before dbSendQuery(t.con, t.sql)
> and fetch()
> might work.
> http://dev.mysql.com/doc/refman/5.6/en/charset-connection.html
>
> You might alternatively change the default values for these
> character_set_* variables in MySQL database.
>
> On 2012/02/09, at 3:24, Henri Mone wrote:
>
>> Dear R Users and Experts,
>>
>> I got a MySQL table with German special characters (umlaute like ä,ö,ü
>> etc.) . The MySQL database table is in the UTF8 format, and if I
>> submit a query over the MySql client the umlaute are displayed
>> correctly. If I submit the same query via R the umlaute are displayed
>> wrong. That is a little confusing for me, R as well as the MySQL
>> support UTF8.
>> Is there any option which I should use to get the umlaute in R correct?
>>
>> Thanks,
>> Henri
>>
>>
>>> t.m <-dbDriver("MySQL")
>>> t.con <- try(dbConnect(t.m))
>>> t.rs <- try(dbSendQuery(t.con, t.sql))
>>> t.data <- fetch(t.rs,-1)
>>> t.data  # correct would be "Österreichische Schilling"
>>  \xd6sterreichische Schilling
>>  ...
>>
>> _______________________________________________
>> R-sig-DB mailing list -- R Special Interest Group
>> R-sig-DB at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-db
>>
>



More information about the R-sig-DB mailing list