What are some potential reasons for Umlauts being replaced by special characters like "„" when using shell_exec in PHP?

When using shell_exec in PHP, special characters like "„" may replace Umlauts due to encoding issues. To solve this problem, you can set the encoding of the command executed by shell_exec to UTF-8 using the iconv function.

$command = 'your_command_here';
$encoded_command = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $command);
$output = shell_exec($encoded_command);