On Sun, 11 Jan 2009, Daniel Sabanés Bové wrote:

Yes, I set the encoding to UTF-8 in my .Rprofile. Sorry that I didn't

You really don't want to do that: it adds a considerable overhead and relies on a bug-free iconv ....

The latest R-patched should work around this.

mention it already. So the complete stand-alone test code which fails in
R --vanilla is the following:

### code begin
options (encoding = "utf-8")
testChunk <- paste(rep("a", 10000 + 1), ## delete "+ 1" to be successful
                  collapse="")
output <- tempfile()
cat(testChunk, sep = "\n", file = output, append = TRUE)
### code end

And the version and locale of my system are

R version 2.8.1 (2008-12-22)
i686-pc-linux-gnu
locale:
LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=C;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE.UTF-8;LC_IDENTIFICATION=C


Prof Brian Ripley schrieb:
Looks like a bug in your iconv.  However, that section of code is
conditionalized by

    if(con->outconv) { /* translate the buffer */

and I don't see that as non-NULL on my systems.  It should only be
called when you specify an encoding on the output connection, so have
you set an option (e.g. "encoding")  without telling us?

I was able to reproduce a similar problem by

cat(testChunk, sep = "\n", file = file("output", encoding="latin1"),
    append = TRUE)

in a UTF-8 locale, and I'll add a workaround to the R sources.

Please do run your tests with R --vanilla and make sure they are
complete -- see the posting guide.


On Mon, 5 Jan 2009, Daniel Sabanés Bové wrote:

Dear Prof. Ripley,
I have discovered that my cat function cannot write more than 10000
characters to a text file.

I think you meant *bytes*, BTW.



--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to