`format`对UTF-8字符串有什么作用? [英] What does `format` do to UTF-8 strings?

查看:162
本文介绍了`format`对UTF-8字符串有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在文档中,format应该执行以下操作:

From the documentation, format should do the following:

格式化R对象以进行漂亮的打印.

Format an R object for pretty printing.

现在,如何使用以下示例:

Now how does that go along with the following example:

> format("\u2264")
[1] "="

任何人都可以解释发生了什么事吗?

Can anyone explain what is going on?

我在Windows上使用R.该问题出现在R 3.3、3.4和3.5中. 该问题在Linux上没有出现.

I'm using R on Windows. The problem appears in R 3.3, 3.4 and 3.5. The problem does not appear on Linux.

推荐答案

从R ="nofollow noreferrer">文档:

[returns]与x具有相似结构的对象,以通用格式包含第一个参数x的元素的字符表示,并且(强调我的)采用当前语言环境的编码.

您可以尝试运行Sys.getenv("LANG")来查看当前的R环境编码是什么.假设它是UTF-8,那么看到是有意义的,因为这是Unicode文字\u2264的UTF-8表示形式.

You may try running Sys.getenv("LANG") to see what your current R environment encoding is. Assuming it be UTF-8, then seeing makes sense, as this is the UTF-8 representation of the Unicode literal \u2264.

注意:在我的R工具中,我得到作为format("\u2264")的输出,与Unicode表相比是正确的.也许您的问题中有错字.

Note: I get as the output for format("\u2264") in my R tool, which is correct as compared against the Unicode tables. Perhaps you have a typo in your question.

这篇关于`format`对UTF-8字符串有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆