From ripley at stats.ox.ac.uk  Sun Jan 11 18:41:20 2009
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sun, 11 Jan 2009 17:41:20 +0000 (GMT)
Subject: [Rd] cat cannot write more than 10000 characters? [R 2.8.1]
In-Reply-To: <496A13ED.1090208@campus.lmu.de>
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>
	<496A13ED.1090208@campus.lmu.de>
Message-ID: <alpine.OSX.1.00.0901111739110.33178@tystie.local>

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,                  ripley at 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


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