Question

I am making a R package of my own. However, I am having encoding problems with package help.

For the record, I need to write package help in Chinese. I write .Rd file with the following additional setup according to the document of writing R extention:

  • add \encoding{utf-8} to the first line of each .Rd file
  • save .Rd file as utf-8 encoded without BOM

And here are the results: + the CJK characters in the description section are correctly recognized in the help window of RStudio. + R compiler fails if there are CJK characters in the title section with the following message:

*** installing help indices
Error in gsub("&", "&", x, fixed = TRUE) :
  invalid multibyte string at '<84> <74>op k €'

I believe international documents for R are necessary. Are there anyone has experience on this?

Was it helpful?

Solution

Two fixes in install.r

  • add useBytes=T for gsub() in htmlize()
  • within .writePkgIndices(), add encoding='UTF-8' to outcon
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top