tomcai tomcai - 7 months ago 35
R Question

when use rstudio make r package, the package cant output chinese words,why?

I try to use rstudio to make r package. but the package cant print the right words.

below is the code in package:

hello3 <- function(){

but when use the package ,the output is :

> library(hr)
> hello3()
[1] "娴嬭瘯"

It's evident that the output text into other encodings.

What reason is this?

How to solve this problem?


Using multi-byte characters in your source code makes a lot of headache. I would use unicode expression as below.

hello3 <- function() 


[1] "测试"

If you do not know what is the right expression for your words, try:

sprintf("%x", utf8ToInt("测试"))
[1] "6d4b" "8bd5"