在 R 中将非 ASCII 转换为以反斜杠 u (\u) 开头的字符表示?
Convert non-ASCII to character representations beginning with backslash u (\u) in R?
运行 R CMD check --as-cran
给出
Portable packages must use only ASCII characters in their R code,
except perhaps in comments.
Use \uxxxx escapes for other characters.
什么是 \uxxxx
,更重要的是,我如何将非 ASCII 字符转换成它们?
到目前为止我所知道的
?iconv
信息量很大,看起来很强大,但我看不到 \u
的形式
- this python 文档表明
\uxxxx
是
Character with 16-bit hex value xxxx (Unicode only)
问题
如何将非 ASCII 字符转换为 \uxxxx
形式的字符表示
一些例子c("¤", "£", "€", "¢", "¥", "₧", "ƒ")
你有 stri_escape_unicode
来自 stringi 来转义 unicode:
stringi::stri_escape_unicode(c("¤", "£", "€", "¢", "¥", "₧", "ƒ"))
## [1] "\u00a4" "\u00a3" "\u20ac" "\u00a2" "\u00a5" "P" "\u0192"
我有一个基于它的插件,用于删除函数中引号之间的非 ascii 字符:https://github.com/dreamRs/prefixer
运行 R CMD check --as-cran
给出
Portable packages must use only ASCII characters in their R code,
except perhaps in comments.
Use \uxxxx escapes for other characters.
什么是 \uxxxx
,更重要的是,我如何将非 ASCII 字符转换成它们?
到目前为止我所知道的
?iconv
信息量很大,看起来很强大,但我看不到\u
的形式
- this python 文档表明
\uxxxx
是
Character with 16-bit hex value xxxx (Unicode only)
问题
如何将非 ASCII 字符转换为 \uxxxx
一些例子c("¤", "£", "€", "¢", "¥", "₧", "ƒ")
你有 stri_escape_unicode
来自 stringi 来转义 unicode:
stringi::stri_escape_unicode(c("¤", "£", "€", "¢", "¥", "₧", "ƒ"))
## [1] "\u00a4" "\u00a3" "\u20ac" "\u00a2" "\u00a5" "P" "\u0192"
我有一个基于它的插件,用于删除函数中引号之间的非 ascii 字符:https://github.com/dreamRs/prefixer