[R-SIG-Mac] locales on OS X [Was: Lion and X11]

Simon Urbanek simon.urbanek at r-project.org
Sat Jan 28 23:56:24 CET 2012


Christian,

what exactly are you talking about? This is entirely unrelated to the thread you replied to and you're mixing several completely unrelated things below. The locale is set by your system, not by R. To break down the situations:

- R on the console uses the locale set by the shell it is run from. The most common cases:

a) in Terminal the encoding is set in the Terminal's preferences (Advanced->International->Character encoding) and the default is UTF-8. If you change it in your shell startup files, it will be overridden.

b) xterm inherits your local shell/login settings which are unset by default so you will be in C locale (assuming you didn't start xterm from Terminal - then a) applies, obviously)

- R.app GUI uses your system settings (System Preferences -> Language & Text) for the language and UTF-8 for encoding. If your settings are inconsistent (conflicting language and format settings) it will give you a warning and fall back to C. The GUI is designed to work only in the UTF-8 encoding. The "defaults write org.R-project.R force.LANG en_US.UTF-8" command only affects the R.app GUI and has the same effect as setting "LANG" to that value in the shell - in your case you are setting the locale to US english and encoding to UTF-8.

R doesn't care which locale you run it in - it is entirely up to you. You get what you ask for :). Only the R.app GUI cares since all I/O is in UTF-8 so you should either pick a UTF-8 locale or set your system properly, otherwise you'll get errors when using non-ASCII characters in file names etc.

I hope it helps.

Cheers,
Simon


On Jan 28, 2012, at 2:57 PM, cstrato wrote:

> Here is one more confusing issue:
> 
> I know that sessionInfo() gives
> locale:
> [1] C
> 
> This was the case when starting R64.app or starting R from the command line. Following the advice from an earlier topic I did on the command line:
> $ defaults write org.R-project.R force.LANG en_US.UTF-8
> 
> Since starting R on the command line did not change anything I tried this a couple of times. This did not change anything when starting R from xterm, but now I the following effect on R64.app.
> Here the sessionInfo() now gives
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
> 
> Now I have no idea how to get rid of these locales on R64.app and how to get the correct locale on R started on xterm.
> 
> BTW, I do know the following mails:
> https://stat.ethz.ch/pipermail/r-sig-mac/2012-January/008945.html
> https://stat.ethz.ch/pipermail/r-sig-mac/2012-January/008948.html
> 
> The proposed solution is to add in .bahrc:
> export LC_CTYPE=en_US.UTF-8
> export LC_ALL=en_US.UTF-8
> 
> However, I am not sure if this is the correct solution or only a workaround for the following reasons:
> 1, I have always installed R-x.pkg from Simon since many years on Tiger, Leopard, and Snow Leopard and never had to add anything to .bashrc.
> 2, All my OS X versions are set to US English (and not to German).
> 
> So my questions are:
> - Why does installing R-2.14.1.pkg on Lion cause the problem with the locale?
> - Did anything change on Lion?
> - Do I really have to use the workaround to add above lines to .bashrc?
> 
> Best regards
> Christian
> _._._._._._._._._._._._._._._._._._
> C.h.r.i.s.t.i.a.n   S.t.r.a.t.o.w.a
> V.i.e.n.n.a           A.u.s.t.r.i.a
> e.m.a.i.l:        cstrato at aon.at
> _._._._._._._._._._._._._._._._._._
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 
> 



More information about the R-SIG-Mac mailing list