Inserting reference with accented characters in roxygen2 documentation using bibtex

I am developing a package in RStudio using roxygen2 and in the object documentation I would like to cite references that have accented characters. I am following the instructions here. Unfortunately, the accented characters do not appear correctly when I view the documentation in my browser after building the package.

Here is the function with roxygen2 tags above:

#' A function called foo
#'
#' I want to cite a reference with accented characters in author's name:
#'    \insertCite{Cube19}{justtestingonly}
#'
#' @param uhhh An object
#' @export
#' @encoding UTF-8
#' @references{\insertAllCited{}}
#' @importFrom Rdpack reprompt

foo <- function(uhhh) {}

Here is my bibtex entry in the file REFERENCES.bib in inst folder:

@ARTICLE{Cube19,
	author={Thomas {\c C}{\"u}be},
	title={article title},
	journal={Journal of Stuff},
	year={2019},
	volume={1},
	number={1},
	pages={10--11},
}

My DESCRIPTION file includes the lines

Imports: Rdpack
RdMacros: Rdpack
Encoding: UTF-8

In my browser the citation appears as (Çübe 2019) rather than (Çübe 2019).

Can't you just write the UTF-8 characters into the REFERENCES.bib file?

No, that was what I tried first. I ended up emailing Georgi Boshnakov about the issue and the substance of his response was as follows:

This is Windows related, see some details below. If you build the package on Linux or Mac, then the rendering should be OK. I will be happy to have a look if you send me the package.

I know that this is not a real solution for a Windows user (which I am too, although for development I have moved almost entirely to linux), at least there are no errors and warnings from the R tools about this. I am surprised that nobody has asked about it before. I should update the docs.

This is an issue on Windows with Uncode, which to my knowledge is unsolvable in certain contexts, without extensive hacks or sacrificing something else (for example, specifying a latin1 encoding for the package, but that is clearly inferior). Windows doesn’t have “UTF-8” locale. As a result, it approximates letters it doesn’t know. The issue pops up in various contexts in R and is a common source of questions on R-devel.

As an example, the extract below is from a discussion on R-devel (Tomas Kalibera is from the R Core Team) at https://r.789695.n4.nabble.com/Printing-chinese-characters-UTF-8-on-R-3-5-2-windows-10-td4759266.html

2 Likes