美文网首页
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 一下

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