Bugzilla – Bug 15227
cat with bad UTF8 strings from intToUtf8 can make R GUI hang
Last modified: 2013-03-07 13:00:08 UTC
Using the intToUtf8 function it is possible to create UTF8 strings that cause R to hang when outputted to the R GUI console with cat.
If the string contains an end of text character followed by any non-ASCII character, then cat will fail ungracefully.
bad_string <- intToUtf8(c(3, 128))
The non-ASCII characters (values > 127) are necessary; if they are not included then R considers the encoding of the string to be "unknown" rather than "UTF8".
catting to file works OK.
cat(bad_string, file = "test.txt") #ok
I've reproduced the problem under Win7 with 32 and 64 bit versions of R2.15.2 and a recent R3.0.0-devel.
The problem doesn't occur when using R from the command line, or other IDEs (RStudio tested).
I can reproduce this and will investigate, but it might turn out to be a Windows bug rather than an R bug. It doesn't happen on other platforms.
Turned out it was our bug, now fixed in R-devel and 3.0.0-to-be.