Skip to content

Unicode characters in script?

6 messages · Michael Hoban, R Erickson, Simon Urbanek +1 more

#
Hi all-

I tried searching before posting, but this is one of those tricky
questions to search for. My issue is this: within the R.app gui, I can
use extended characters in plot labels without any issue (specifically
in my case the ?, lowercase delta), for example:
However, when I try to do the same in a script from the terminal
(interpreted by Rscript), I get a bunch of errors related to character
encoding:
  ....
  conversion failure on '?foobie bletch?' in 'mbcsToSbcs': dot
substituted for <e2>
  ....

Is there a way to make this work? Or is Rscript not equipped to handle
multibyte characters?

thanks in advance,

_mykle
#
I have, it doesn't seem to make a difference. It looks like the
problem concerns the PDF output device being used from Rscript as
opposed to quartz in R.app.
On Thu, Aug 11, 2011 at 1:26 PM, R Erickson <raerickson at gmail.com> wrote:
#
On Aug 11, 2011, at 2:35 PM, Michael Hoban wrote:

            
It seems your'e running Rscript in a locale that doesn't support unicode (probably C). Make sure you use UTF-8 locale (e.g. LANG=en_US.UTF-8)

Cheers,
Simon
#
On Thu, 11 Aug 2011, Simon Urbanek wrote:

            
Maybe: but because he blatently ignored the posting guide, we don't 
know.

Another possibility is that he is using a graphics device that does 
not support those characters (and again, we have not been told).

Using Greek characters requires the postscript() and pdf() devices to 
be told to work in Greek, as their help pages (and the R manuals) 
makes clear.  It is those graphics languages (and not Rscript) which 
do not support Unicode.  You will also need viewers that support the 
Greek characters ....
#
In my first posting, I didn't know there were two different graphics
output mechanisms at work. In my second, I had found that out. The
same code in two places uses different back-ends, and produces
different output results, and it was by no means immediately apparent
that that's the case. I meant no slight against Rscript itself or by
extension its author. In all of the documentation I read, there was
nothing that explicitly said that the figures produced by R.app were
fundamentally different from those generated from the command line
(especially as the default format for saving from R.app figures is
pdf). Also, if I generate the figure from within R.app and save it as
a PDF, it "just works," further leading me to assume it should "just
work" from the command line. Sorry for the confusion.




On Thu, Aug 11, 2011 at 11:23 PM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote: