[R-SIG-Mac] [R] data frames with å, ä, and ö (=non-ASCII-characters) from windows to mac os x

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jan 16 15:13:59 CET 2009

On Fri, 16 Jan 2009, David Winsemius wrote:

> Reading the help page for Sys.get/set/locale:
> "Attempts to change the character set (by Sys.setlocale("LC_TYPE", ), if that 
> implies a different character set) during a session may not work and are 
> likely to lead to some confusion.
> Value
> A character string of length one describing the locale in use (after setting 
> for Sys.setlocale), or an empty character string if the current locale 
> settings are invalid or NULL if locale information is unavailable.
> For category = "LC_ALL" the details of the string are system-specific: it 
> might be a single locale name or a set of locale names separated by 
> "/"(Solaris, Mac OS X) or ";" (Windows, Linux). For portability, it is best 
> to query categories individually: it is not necessarily the case that the 
> result of foo <- Sys.getlocale() can be used in Sys.setlocale("LC_ALL", 
> locale = foo).'
> I interpret that as saying that if you use "LC_ALL", then you need to pass a 
> character string to Sys.setlocale() that is constructed properly for a Mac 
> and that it might have "/"'s.

Actually, it says the opposite: the output you get is not necessarily 
valid input.

> And you need to do it at the beginning of a 
> session. And that it will be ignored, as you say "not do anything" if not 
> precisely correct. This is what Sys.getlocale returns on mine:
> "en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8"

However, to set it, just en_US works (Mac locales are by default in 
UTF-8).  In Swedish, you can have:

tystie% locale -a | grep SE

and setting one of the middle two would have worked.

Annoyingly, Mac OS does not tell you which is which in the locales 
settings list, so it is basically useless.  I believe they are 
alphabetic (in the C locale) order since the Mac only has 6 

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-SIG-Mac mailing list