From mdowle at mdowle.plus.com  Mon Jul 16 14:15:03 2012
From: mdowle at mdowle.plus.com (Matthew Dowle)
Date: Mon, 16 Jul 2012 13:15:03 +0100
Subject: [Rd] Non ascii character on Mac on CRAN (C locale)
Message-ID: <4e2b012d65582cdd75c0ca0db7c864c1.squirrel@webmail.plus.net>


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



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