I\'ve got a command which I\'m running from PHP using shell_exec(). Sometimes the output of the command will contain accented characters.
When run from Bash, the output
The solution that worked for me was to run these commands before shell_exec, to make sure that the correct locale was being used:
$locale = 'en_GB.utf-8';
setlocale(LC_ALL, $locale);
putenv('LC_ALL='.$locale);
Presumably you can just change en_GB to whatever your language is. I noticed that the locale string seems to be case sensitive.