When running R inside rApache, the locale is inherited from the Apache webserver, and therefore Sys.getlocale() is always equal to "C". I would like my web application to use UTF8, so I use:
Sys.setlocale("LC_ALL", 'en_US.UTF-8')
However this doesn't work on machines that do not have this locale available:
1: Setting LC_CTYPE failed, using "C"
2: Setting LC_COLLATE failed, using "C"
3: Setting LC_TIME failed, using "C"
4: Setting LC_MESSAGES failed, using "C"
5: Setting LC_MONETARY failed, using “C”
Is there any way to use Sys.setlocale to set the locale to the system default UTF-8? I.e. something that would also work on Windows or a German Linux?
Answering my own question: On Ubuntu the default
LANGis defined in/etc/default/locale:So in R we could do something like:
Apache also has a line in
/etc/apache2/envvarsthat can be uncommented to enable this.