即使它被读作UTF-8,tolower也会在线上抛出错误

时间:2015-08-24 22:04:23

标签: r utf-8 lowercase

当将一些线条变成小写时,R会抛出一个我没想到的错误。

Error in tolower(readLines(x, encoding = "UTF-8")) : 
  invalid input '/home/nobackup/SONAR/COMPACT/WR-P-E-L/WR-P-E-L0000106.data.ids.xml:  <sentence>Fijne dag en take care ðŸ€</sentence>' in 'utf8towcs'

ðŸ€是罪魁祸首。但是,为什么会这样呢?我认为这是一个编码问题,但我的readLines函数清楚地表明编码必须是UTF-8。发生了什么事?

x的示例数据:

/home/nobackup/SONAR/COMPACT/WR-P-E-L/WR-P-E-L0000106.data.ids.xml:  <sentence>Take care !</sentence>
/home/nobackup/SONAR/COMPACT/WR-P-E-L/WR-P-E-L0000106.data.ids.xml:  <sentence>Take care meisje X</sentence>
/home/nobackup/SONAR/COMPACT/WR-P-E-L/WR-P-E-L0000106.data.ids.xml:  <sentence>Hele fijne dag en take care ☀⛄</sentence>

我知道解决方案(我发现this one works best)但我想知道为什么编码不能正常工作。出了什么问题?

0 个答案:

没有答案