[kepler-dev] [Bug 4270] - RExpression exports special characters in strings as the 2 character escaped sequence

bugzilla-daemon at ecoinformatics.org bugzilla-daemon at ecoinformatics.org
Tue Jul 28 16:25:13 PDT 2009


http://bugzilla.ecoinformatics.org/show_bug.cgi?id=4270





------- Comment #2 from soong at nceas.ucsb.edu  2009-07-28 16:25 -------
I think it'd be better to handle this more rigorously by searching specifically
for special escape sequences (\", \\, \n, and \t at least) and converting them.
 There's the java.lang.string.replaceAll function which would probably work. 
Even better would be to actually figure out what all the sequences converted by
R's dput are.

I haven't studied the RExpression.java code about this, but I think Kepler's
catching the R stdout stream and parsing it.  In that case, I think another
alternative might be to replace the dput with a cat.  I believe it would
replace the escape sequences with the appropriate characters in stdout. 
Consider these R commands: 

a <- c("a\\b", "c\"d", "e\nf", "g\th")
dput(a)
cat("c(\"", paste(a, collapse = "\", \""), "\")\n", sep = "")
cat("{\"", paste(a, collapse = "\", \""), "\"}\n", sep = "")

The only problem is what exactly happens on the RExpression side when it
encounters one of these special characters.  I think it might be easier to just
continue with the dput and careful use of replaceAll.


More information about the Kepler-dev mailing list