0

I'm doing an R package. In a roxygen2 example, there is an accented letter:

#' @examples 
#' ......
#'   plateDesign = list(
#'     "design" =
#'       data.frame(
#'         "col1" = "BSCPDSPX01 T0 Far",
#'         "col2" = "Buffer PD Optimisé Far", # <-- accented letter here
#'         "col3" = "No reference selected",
#'         "col4" = "Blue",
#'         "col5" = 2,
#'         stringsAsFactors = FALSE
#'       ),
#' ......

When I run this example locally, there's no issue. But there's an error if it is ran with R CMD CHECK or with devtools::run_examples().

Here is what one can see when one runs devtools::run_examples():

   data.frame(
     "col1" = "BSCPDSPX01 T0 Far",
     "col2" = "Buffer PD Optimisé Far",

What should I do to handle this accented letter? My files are saved in UTF-8 encoding.

The issue also occurs in the .Rd file:

  data.frame(
    "col1" = "BSCPDSPX01 T0 Far",
    "col2" = "Buffer PD Optimisé Far",
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
  • 1
    My default approach to such issues would be to replace the letter with its utf-8 code, i.e. `"Optimis\u00E9"`. – stefan Jul 09 '21 at 11:44
  • Perhaps this post is useful: [Is it possible to write package documentation using non-ASCII characters with roxygen2?](https://stackoverflow.com/questions/43850229/is-it-possible-to-write-package-documentation-using-non-ascii-characters-with-ro) – Henrik Jul 09 '21 at 11:47
  • 1
    @stefan If I do that, this seems to work. So that's a good step. But there's a problem: when I open the help topic, the `"é"` is rendered as `"\u00E9"`. – Stéphane Laurent Jul 09 '21 at 11:49
  • 1
    Aw. Yeah. For the docs this doesn't look pretty. What about the solution in the post linked by @henrik? I have put the snippet of your example code in a toy package and it works fine on my machine without any complaints about Non-ASCII characters. However, when removing `Encoding: UTF-8` from the DESCRIPTION I was able to reproduce your error/warning. – stefan Jul 09 '21 at 12:17

0 Answers0