I need to address UTF-8 filenames with the php exec command. The problem is that the php exec command does not seem to understand utf-8. I use something like this:
echo exec('locale charmap');
returns ANSI_X3.4-1968
looking at this SO question, the solution lookes like that:
echo exec('LANG=de_DE.utf8; locale charmap');
But I still get the same output: ANSI_X3.4-1968
On the other hand – if I execute this php command on the bash command line:
php -r "echo exec('LANG=de_DE.UTF8 locale charmap');"
The output is UTF-8.
So the questions are:
- Why is there an different result be executing the php command at bash and at apache_module/web page?
- How to set UTF-8 for
execif it runs inside a website as apache module?
To answer my own question – i found the following solution:
setting the locale environment variable with PHP
This sets to / returns
UTF-8. So i’m able to pass special characters and umlauts to linux shell commands.