[Rd] Non ascii character on Mac on CRAN (C locale)

Matthew Dowle mdowle at mdowle.plus.com
Mon Jul 16 14:15:03 CEST 2012


Dear all,

A recent bug fix for data.table was for non-ascii characters in column
names and grouping by those column. So, the package's test file now
includes non-ascii characters to test that bug fix :

  # Test non ascii characters when passed as character by, #2134
  x = rep(LETTERS[1:2], 3)
  y = rep(1:3, each=2)
  DT = data.table(ÅR=x, foo=y)
  test(708, names(DT[, mean(foo), by="ÅR"]), c("ÅR","V1"))
  test(709, DT[, mean(foo), by="ÅR"], DT[, mean(foo), by=ÅR])
  DT = data.table(FÅR=x, foo=y)
  test(710, names(DT[, mean(foo), by="FÅR"]), c("FÅR","V1"))
  DT = data.table(ÆØÅ=x, foo=y)
  test(711, DT[, mean(foo), by="ÆØÅ"], data.table(ÆØÅ=c("A","B"), V1=2))
  test(712, DT[, mean(foo), by=ÆØÅ], data.table(ÆØÅ=c("A","B"), V1=2))

This passes R CMD check on Linux, Windows and Mac on R-Forge, but not on
Mac on CRAN because Prof Ripley advises that uses the C locale.

It works on Windows because data.table does this first :

  oldenc = options(encoding="UTF-8")[[1L]]
  sys.source("tests.R")  # the file that includes the tests above
  options(encoding=oldenc)

If I change it to the following, will it work on CRAN's Mac, and is this
ok/correct?  Since it passes on R-Forge's Mac, I can't think how else to
test this.

  oldlocale = Sys.getlocale("LC_CTYPE")
  if (oldlocale=="C") Sys.setlocale("LC_CTYPE","en_GB.UTF-8")
  oldenc = options(encoding="UTF-8")[[1L]]
  sys.source("tests.R")  # the file that includes the tests above
  options(encoding=oldenc)
  Sys.setlocalte("LC_CTYPE",oldlocale)

Many thanks,
Matthew



More information about the R-devel mailing list