Skip to content

Rd files with unknown encoding?

4 messages · Spencer Graves, Brian Ripley

#
How can I identify the problem generating a warning in R CMD check 
for "Rd files with unknown encoding"? 

      Google identified an email from John Fox with a reply from Brian 
Ripley about this last 12 Jun 2007.  This suggests that I may have 
accidentally entered some possibly non-printing character into the 
offending Rd file.  The message tells me which file, but I don't know 
which lines in the file.  Is there some way of finding the offending 
character(s) without laboriously running R CMD check after deleting 
different portions of the file until I isolate the problem? 

      Thanks,
      Spencer Graves
#
On Wed, 12 Dec 2007, Spencer Graves wrote:

            
But not on this list:

https://stat.ethz.ch/pipermail/r-devel/2007-June/046055.html

R-devel would have been more appropriate for this too.
I did say so in that thread:

https://stat.ethz.ch/pipermail/r-devel/2007-June/046061.html

You can do much the same in R via iconv("", "C", sub="byte"), provided you 
can read the file in (it may not be representable in your current 
locale, but you could run R in a Latin-1 locale, if your OS has one).
2 days later
#
Dear Prof. Ripley: 

      Thanks very much.  I did as you suggested, which I'll outline here 
to make it easier for anyone else who might have a similar problem: 

           * Read the offending *.Rd file in R using 'readLines' 

           * Applied 'iconv' to the character vector, following the last 
example in the help file.  This translated all offending characters into 
a multi-character sequence starting with '<'. 

           * Used 'regexpr' to find all occurrences of '<'. 

      The latter identified other uses of '<' but produced a 
sufficiently short list that I was able to find the problems fairly 
easily. 

      Thanks again.
      Spencer Graves   
p.s.  And in the future, I will refer 'Rd' questions to 'R-devel', per 
your suggestion.
Prof Brian Ripley wrote:
1 day later
#
Here's a slightly cleaner version:

showNonASCII <- function(x)
{
     ind <- is.na(iconv(x, "latin1", "ASCII"))
     xxx <- iconv(x[ind], "latin1", "ASCII", sub="byte")
     if(any(ind)) cat(which(ind), ": ", xxx, "\n", sep="")
}

used as

        
On Sat, 15 Dec 2007, Spencer Graves wrote: