【发布时间】:2015-03-20 13:43:05
【问题描述】:
我有一个 UTF-8 字符串,需要 1)gsub 特殊符号,2)将整个数据帧转换为“正常”(ASCII?)编码。但是,我无法在其上运行 gsub - 没有捕捉到字符串。
我在French 语言环境中工作(尝试过 UTF-8),但没有获得批准。
无法为您提供完整的数据集,但会在此处发布几个字符串。
DataFrame = read.csv("SLD_products_FullData.csv",header=F,sep=",",encoding = "UTF-8")
title = DataFrame$title
这就是标题在控制台中的样子:
"Campbell’s Gravy and General Mills • Cheerios"
在查看器中:
Campbell’s Gravy and General Mills • Cheerios"
尝试过(各种 perl、固定等):
gsub("’","'",title)
gsub("•","-",title)
甚至尝试过gsub("’","'",title)。没有运气。
Encoding(title)
[1] "UTF-8"
有什么建议吗?谢谢!!