Unicode in cgi-script with apache2
Peter Otten
__peter__ at web.de
Sun Aug 17 10:06:38 EDT 2014
Dominique Ramaekers wrote:
> And if I check the encoding with the python script (uncommenting line
> #1), I still get ANSI_X3.4-1968
That should not matter as long as
print(os.environ.get("PYTHONIOENCODING"))
prints
UTF-8
If you do get the correct PYTHONIOENCODING you should be able to replace the
corresponding SetEnv with
SetEnv LANG en_US.UTF-8
or similar. If you don't get the expected value the SetEnv is probably not
in the right place. In my experiments I put it into
/etc/apache2/sites-enabled/000-default.conf
in an apache installation I think I have not tinkered with before ;)
While looking around in the apache configuration I also found the file
/etc/apache2/envvars. Here's an excerpt:
## The locale used by some modules like mod_dav
export LANG=C
## Uncomment the following line to use the system default locale instead:
#. /etc/default/locale
export LANG
If you uncomment the line
. /etc/default/locale
and replace
SetEnv LANG en_US.UTF-8
with
PassEnv LANG
you should get a similar effect assuming your system defaults to UTF-8.
More information about the Python-list
mailing list