[Rd] cat cannot write more than 10000 characters? [R 2.8.1]

Daniel Sabanés Bové daniel.sabanesbove at campus.lmu.de
Sun Jan 11 16:44:45 CET 2009


Yes, I set the encoding to UTF-8 in my .Rprofile. Sorry that I didn't
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.
>



More information about the R-devel mailing list