美文网首页
R语言编码问题,Mark 一下

R语言编码问题,Mark 一下

作者: juriau | 来源:发表于2018-10-10 15:57 被阅读29次

例如:\345\244\247\345\256\266\345\245\275\343\200\202 对应汉字是“大家好。"
8进制表示法.将以上每组按8进制转换成16进制是
E5 A4 A7 E5 AE B6E5 A5 BD

汉字的UTF-8码, 以上三个字每字三字节.
如果用JS的话,可以用encodeURI方法进接对汉字进行编码,得到 %E5%A4%A7%E5%AE%B6%E5%A5%BD 然后将每组16进制转换为8进制,将%替换为\就行了.


Q:
WARNING: You're using a non-UTF8 locale, therefore only ASCII characters
will work.

Please read R for Mac OS X FAQ (see Help) section 9 and adjust your system
preferences accordingly.

A:
7 Internationalization of the R.app

R and the R.app GUI introduced support for internationalization in R 2.1.0. Among other things this means that both messages and GUI elements can be translated into various languages. R.app automatically detects user's settings in the International section of the System Preferences and uses that information to offer translated messages and GUI if available. Please note that both Language and Formats information is used so they should be set up consistently.

If you use a non-standard setup (e.g. different language than formats), you can override the auto-detection performed by setting `force.LANG' defaults setting, such as for example

defaults write org.R-project.R force.LANG en_US.UTF-8
when run in Terminal it will enforce US-english setting regardless of the system setting. If you don't know what Terminal is you can use this R command instead:

system("defaults write org.R-project.R force.LANG en_US.UTF-8")
but do not forget to quit R and start R.app again afterwards. Please note that you must always use `.UTF-8' version of the locale, otherwise R.app will not work properly.

By default R.app uses UTF-8 for newly created documents and for the console. When opening new documents R.app assumes UTF-8 and only if the document violates UTF-8 rules, it will try to fallback to legacy encoding, usually Mac Roman.

If you are interested in translating R.app GUI into other languages, please read the developer documentation at http://developer.r-project.org/Translations30.html.

翻译:

7 R.app的国际化

R和R.app GUI在R 2.1.0中引入了对国际化的支持。除此之外,这意味着消息和GUI元素都可以翻译成各种语言。 R.app会自动检测系统偏好设置的国际部分中的用户设置,并使用该信息提供已翻译的消息和GUI(如果可用)。请注意,使用语言和格式信息,因此应始终如一地设置它们。

如果您使用非标准设置(例如,不同于格式的语言),您可以通过设置`force.LANG'默认设置来覆盖执行的自动检测,例如

默认值写org.R-project.R force.LANG en_US.UTF-8
当在终端中运行时,无论系统设置如何,它都将强制执行美国英语设置。如果您不知道什么是终端,则可以使用此R命令:

system(“defaults write org.R-project.R force.LANG en_US.UTF-8”)
但是不要忘记退出R然后再次启动R.app。请注意,您必须始终使用语言环境的`.UTF-8'版本,否则R.app将无法正常工作。

默认情况下,R.app将UTF-8用于新创建的文档和控制台。在打开新文档时,R.app采用UTF-8,并且只有当文档违反UTF-8规则时,它才会尝试回退到传统编码,通常是Mac Roman。

如果您有兴趣将R.app GUI翻译成其他语言,请阅读http://developer.r-project.org/Translations30.html上的开发人员文档。

相关文章

  • R语言编码问题,Mark 一下

    例如:\345\244\247\345\256\266\345\245\275\343\200\202 对应汉字是...

  • 2020-11-02DAY4-添添-R语言基础

    1、下载R和Rstudio 2、认识R和Rstudio R是一种编码语言,Rstudio是使用R语言的图形界面,接...

  • R语言基础学习(一)

    分享一下之前的笔记,顺带mark一下,减轻电脑存储负荷! R语言基础学习 数据分析的过程数据采集(笔记,pytho...

  • R语言编码风格

    ——by不是杀杀 为了使我们写的代码更容易阅读、避免过段时间再看自己写的代码就头疼,我们在写代码的时候应该注意一些...

  • R语言编码规范

    1.一般性规则 (1)避免使用attach。(2)写函数时尽量少的使用stop()。(3)定义S3和S4的对象不要...

  • RedisJSON(JReJSON)中文编码问题

    指路牌 RedisJSON 中文编码问题 Java RedisJSON - JReJSON 中文编码问题 背景 R...

  • R——useful function

    近期学习R语言,对于常见的函数进行汇总,mark一下,以后方便查看,哈哈! 基础函数 排序函数 筛选函数 交集并集...

  • R|来自 Google 的 R 语言编码风格指南

    R 语言是一门主要用于统计计算和绘图的高级编程语言. 这份 R 语言编码风格指南旨在让我们的 R 代码更容易阅读、...

  • UltraEdit 高亮显示R代码

    UltraEdit 默认高亮显示格式没有R,可以通过添加,实现R语法高亮显示。编码>添加其他语言 找到R,勾选即可。

  • UI(二十三)KVC和KVO

    #pragma mark---KVC--- KVC:key(键)-value(值)-code(编码) 键值编码-...

网友评论

      本文标题:R语言编码问题,Mark 一下

      本文链接:https://www.haomeiwen.com/subject/owapaftx.html