経由で外部プログラムを呼び出す PHP スクリプトを使用していますが、そのshell_exec
出力に興味があります。問題は、ロシア語の文字を使用すると、出力が常に疑問符になることです。
すべてがUbuntu 11.10で実行され、外部プログラムがbashで実行されると、正しい出力が得られます(疑問符はありません)。
私が持っているコードは次のとおりです。
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);
}