From daniel.sabanesbove at campus.lmu.de  Sun Jan 11 16:44:45 2009
From: daniel.sabanesbove at campus.lmu.de (=?UTF-8?B?RGFuaWVsIFNhYmFuw6lzIEJvdsOp?=)
Date: Sun, 11 Jan 2009 16:44:45 +0100
Subject: [Rd] cat cannot write more than 10000 characters? [R 2.8.1]
In-Reply-To: <alpine.OSX.1.00.0901111413260.17084@tystie.local>
References: <4960F7E8.2000705@campus.lmu.de>
	<alpine.LFD.2.00.0901050926040.32650@auk.stats.ox.ac.uk>
	<4961E90F.3040508@campus.lmu.de>
	<alpine.OSX.1.00.0901111413260.17084@tystie.local>
Message-ID: <496A13ED.1090208@campus.lmu.de>

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.
>



[Rd] cat cannot write more than 10000 characters? [R 2.8.1]
=?UTF-8?B?RGFuaWVsIFNhYmFuw6lzIEJvdsOp?=