简体   繁体   English

PHP shell_exec输出问号

[英]PHP shell_exec outputs question marks

I'm using a PHP script that calls external program via shell_exec and I'm interested in it's output. 我正在使用一个PHP脚本,该脚本通过shell_exec调用外部程序,并且我对它的输出感兴趣。 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). 整个过程在Ubuntu 11.10上是runnnig,当以bash执行外部程序时,它将产生正确的输出(无问号)。

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';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM