Skip to content

Unicode changed to symbol in usage section #592

@brry

Description

@brry

Roxygen2 6.0.1 changes unicode statements in function defaults.
In the usage section, rather than keeping \Uxxxx, it writes the represented symbol.
On Windows with German locale, this leads roxygenise to get stopped by an encoding error if run repeatedly.
Here is some code to reproduce the error.

devtools::create("dummypack", list(License="GPL-2"))
devtools::check("dummypack") # no errors, warnings or notes

cat("
  #' Some function
  #' @importFrom graphics plot
  #' @param b Some label
  a <- function(b = '7\\U{00B0}C') {plot(1, main=b)}
", file="dummypack/R/a.R")

devtools::document("dummypack") # works
#Updating dummypack documentation
#Loading dummypack
#Writing NAMESPACE
#Writing a.Rd

devtools::document("dummypack")  # error!!!
#Updating dummypack documentation
#Loading dummypack
#Error in gsub("\n", "\r\n", contents, fixed = TRUE) : 
#  input string 1 is invalid UTF-8

berryFunctions::tryStack(devtools::document("dummypack"))
# devtools::document -> withr::with_envvar -> force -> roxygen2::roxygenise -> 
# unlist -> lapply -> FUN -> roclet_output -> roclet_output.roclet_rd -> 
# mapply -> write_if_different -> same_contents -> gsub -> 
# gsub("\n", "\r\n", contents, fixed = TRUE)[1] "Error in gsub(    [...]

unlink("dummypack/man/a.Rd")
devtools::document("dummypack") # works
devtools::document("dummypack") # error
unlink("dummypack/man/a.Rd")
devtools::check("dummypack") # fails with gsub UTF8 error as well

rd <- readLines("dummypack/man/a.Rd")
rd[7] <- "a(b = \"7\\U{00B0}C\")"
writeLines(rd[-1], "dummypack/man/a.Rd")

devtools::document("dummypack") # works
devtools::document("dummypack") # works
devtools::check("dummypack") # works fine
 
unlink("dummypack", recursive = TRUE)

sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorutf8 🌏wipwork in progress

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions