在R中显示从MySQL检索到的日语字符 [英] displaying Japanese characters retrieved from MySQL in R

查看:107
本文介绍了在R中显示从MySQL检索到的日语字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力在数据框中显示日语字符,这些日语字符已使用RMySQL软件包从MySQL数据库中检索到.如果我将数据库中的字符串粘贴到变量中,该变量具有Encoding'UTF-8',则日语字符显示良好. dataframe列的编码"为未知",我还没有使用iconv对其进行更改.

I am struggling to display Japanese characters in a dataframe, which have been retrieved from a MySQL database using the RMySQL package. Japanese characters display fine if I paste a string from the database into a variable, which then has the Encoding 'UTF-8'. The Encoding of the dataframe column is 'unknown' and I haven't managed to change it using iconv.

数据库的一行是:

1.00    20120801    4520000000000.00    1.00    379.00  142.00  北日本フード スーパー極上キムチ 330g

使用以下方法检索:

rs <- dbSendQuery(con, "select * from sales");
data <- fetch(rs, n=-1)

第一行数据:

1     1 20120801 4.52e+12        1   379    142 ?????????????????????\r

任何帮助都将不胜感激.

Any help greatly appreciated.

推荐答案

问题似乎已经解决,方法是在检索数据之前添加以下行:

The problem seems to be fixed by adding the following line before retrieving that data:

rs <- dbSendQuery(con, 'set character set "utf8"')

这篇关于在R中显示从MySQL检索到的日语字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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