I'm using a PHP script that calls external program via shell_exec
and I'm interested in it's output. The problem is that output always comes as question marks when I use russian letters.
The whole thing is runnnig on Ubuntu 11.10, when external program executed in bash it yields correct output (no question marks).
Here's the code that I have:
setlocale(LC_ALL, "en_US.UTF-8");
echo morpher("Антон");
function morpher($command) {
static $path = '/usr/bin/mono %sengine/helpers/language/morpher.exe %s';
$path = sprintf($path, SITE_ROOT, $command);
$output = shell_exec($path);
error_log($output) // series of question marks instead of russian letters
error_log( mb_detect_encoding($output) ); // outputs ASCII
error_log( iconv('ASCII', 'UTF-8', $output) ); // same question marks
return explode("\n", $output);
}
通过添加LANG="en_US.UTF8"
解决,例如: 'LANG="en_US.UTF8" mono %sengine/helpers/language/morpher.exe %s';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.