问题描述
如何在library\base\R中配置Rprofile,以使默认字符集为UTF-8而不是本机。
How to configure Rprofile in 'library\base\R' so that default charset is UTF-8 rather than native.
配置为行
options(encoding = "native.enc")
我想替代native.enc,我们需要放置UTF-8相关的值。
I suppose in place of native.enc, we need to put UTF-8 relevant value.
推荐答案
从R 3.0.0开始,接受编码UTF-8-BOM进行读取,并删除字节顺序标记(通常用于Microsoft应用程序生成的文件和网页)。如果需要BOM(不推荐),写入时应明确书写,例如通过writeChar(\\\,con,eos = NULL)或writeBin(as.raw(c(0xef,0xbb,0xbf)),binary_con)
As from R 3.0.0 the encoding "UTF-8-BOM" is accepted for reading and will remove a Byte Order Mark if present (which it often is for files and webpages generated by Microsoft applications). If a BOM is required (it is not recommended) when writing it should be written explicitly, e.g. by writeChar("\ufeff", con, eos = NULL) or writeBin(as.raw(c(0xef, 0xbb, 0xbf)), binary_con)
编码名称utf8,mac和macroman不可移植,并且不支持所有当前的R平台。 UTF-8是便携式的,macintosh是Mac Roman的官方(最受欢迎的)名称。
Encoding names "utf8", "mac" and "macroman" are not portable, and not supported on all current R platforms. "UTF-8" is portable and "macintosh" is the official (and most widely supported) name for ‘Mac Roman’.
这篇关于R默认编码为UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!