-Sweave(file=ls.args[1], output=ls.args[2], syntax="SweaveSyntaxNoweb", prefix.string=ls.pr)
+
+# The Sweave version provided with R >= 0.13.1 has proper handling for
+# encodings and our workaround for previous versions does not work
+# anymore. Therefore, the invocation has to be different.
+if (is.null(formals(Sweave)$encoding)) {
+ # set default encoding for input and output files; .orig.enc is used in
+ # the sweave module preamble to reset the encoding to what it was.
+ .orig.enc <- getOption("encoding")
+ options(encoding=.doc.enc)
+ Sweave(file=.cmdargs[1], output=.cmdargs[2], syntax="SweaveSyntaxNoweb",
+ prefix.string=.prefix.str)
+} else {
+ Sweave(file=.cmdargs[1], output=.cmdargs[2], syntax="SweaveSyntaxNoweb",
+ prefix.string=.prefix.str, encoding=.doc.enc)
+}