rapache
rapache copied to clipboard
Setting UTF-8
Using Rapache (1.2.5) I am trying to read an excel file with a Δ character in it. I then write the content back out to csv but end up with "<U+0394>". I found that if I ran the line below before my code, then the csv would get the correct Δ character.
Sys.setlocale("LC_ALL", "en_US.utf8")
I came across this old post that I don't think answers the question: http://stackoverflow.com/questions/20577764/set-locale-to-system-default-utf-8
I am wondering what the best way is to set UTF-8 instead of "C" on an rapache server (given I may use Ubuntu, Centos and other linux flavors).
Thanks, Brian
You could add that code using the REvalOnStartup or RSourceOnStartup directive. That way every time a new apache process is created it gets set.
http://rapache.net/manual.html
Thanks. The real issue is that the rapache locale was different than the default system locale. Rapache was started with an init.d script that didn't fetch the LANG environment variable.
Doing this in the init.d script for the few linux flavors we work with fixed the issue:
Ubuntu
[ -f /etc/default/locale ] && . /etc/default/locale
Centos
[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n export LANG