[R-SIG-Mac] font encoding issue

Martin Maechler maechler at stat.math.ethz.ch
Wed Nov 24 10:31:14 CET 2004


>>>>> "Denis" == Denis Chabot <chabotd at globetrotter.net>
>>>>>     on Tue, 23 Nov 2004 21:17:58 +0100 writes:

    Denis> Hi, I like to comment my programs, and often I do so
    Denis> in French.  But accented vowels in a R editor window
    Denis> get screwed up in the R console, so that

    Denis> # exemple à suivre

    Denis> becomes

    >> # exemple º  suivre

(and this has been changed again by passing through the mail systems)

    Denis> (other french accents become just as ugly).

    Denis> I suppose this is a font encoding error. Can it be
    Denis> fixed, or is there something in R itself which
    Denis> prevents it from even displaying such characters?

No, it's not "R itself", since this works in quite a few other
circumstances in other R consoles: You should be able to use
accents even in strings and plot them, see 
 > example(text)
in R, and even in R object names :

E.g. (in a Linux console):

 > Züri <- "exemple à suivre" # à suivre
 > Züri
 [1] "exemple à suivre"
 >

---------
However it is -- as you write -- an encoding issue,
and probably also depending quite a bit on your so
called "Locale" settings.  To learn more, e.g., see in R

 > apropos("locale")
 [1] "Sys.getlocale"  "Sys.localeconv" "Sys.setlocale"
       
and now, e.g.,
 > ?Sys.getlocale

Here (where I mainly work with Redhat Enterprise Linux) I've
explicitly turned off the Unicode locale (UTF-8 to be specific)
and reverted to "C" (or "POSIX"), by at least setting  'LANG=C'
or 'LANG=POSIX' instead of something like 'LANG=en_US.UTF-8'.

Look at what
  > Sys.getenv("LANG")
tells you, and consider
  > Sys.putenv(LANG = "C")


Martin Maechler, ETH Zurich



More information about the R-SIG-Mac mailing list