我有一个.csv
文件,我将其导入到data.frame
对象中; data.frame
对象然后包含一个字符列,我无法使编码正常工作。
导入的data.frame
如下所示:
df <- data.frame(a = c(1, 2, 3),
b = c("b'Text enth\\xc3\\xa4lt Umlaute \\xe2\\x80\\x93 viele Umlaute.",
"b\"This text doesn't contain any unusual characters.",
"b'another text: http://www.google.com'"))
我尝试失败:
df <- read.csv(filename, fileEncoding = "UTF-8")
(也是= "UTF-8-BOM"
)df <- read.csv(filename, encoding = "UTF-8")
(也是= "UTF-8-BOM"
)和我期望这样的结果:
a b
1 1 "Dieser Text enthält Umlaute – viele Umlaute."
2 2 "This text doesn't contain any unusual characters."
3 3 "another text: http://www.google.com"
(请注意,已转换的\\...
代码段和已删除的b'
/ b\"
)