Ane*_*tte 5 r character-encoding
是否可以在 R 脚本中定义编码?
类似的东西(只是例子):
encoding("utf-8")
Run Code Online (Sandbox Code Playgroud)
我知道在 RStudio 中使用编码重新打开,但我不是在寻找这个。
## x is intended to be in latin1
x <- "fa\xE7ile"
Encoding(x)
Encoding(x) <- "latin1"
x
xx <- iconv(x, "latin1", "UTF-8")
Encoding(c(x, xx))
c(x, xx)
Encoding(xx) <- "bytes"
xx # will be encoded in hex
cat("xx = ", xx, "\n", sep = "")
Run Code Online (Sandbox Code Playgroud)
http://www.inside-r.org/r-doc/base/Encoding
https://stat.ethz.ch/R-manual/R-devel/library/base/html/Encoding.html