/**
* Fix weird output encoding.
*/
function run_command($command) {
$string = shell_exec($command);
$string = mb_convert_encoding($string, 'UTF-8', 'UTF-16LE');
return $string;
}
Source: https://www.reddit.com/r/PHPhelp/comments/de27u8/why_output_of_shell_exec_is_different/f2uwy7s