2012-06-06 110 views
0

我正在使用PHP腳本通過shell_exec調用外部程序,我對它的輸出感興趣。問題在於,當我使用俄語字母時,輸出始終是問號。PHP shell_exec輸出問號

整個事情在Ubuntu 11.10上是runnnig,當外部程序在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); 
} 

回答

0

解決加入LANG="en_US.UTF8"像這樣:'LANG="en_US.UTF8" mono %sengine/helpers/language/morpher.exe %s';