Call a program via shell_exec with utf-8 text input
问题 Perquisites: hunspell and php5 . Test code from bash: user@host ~/ $ echo 'sagadījās' | hunspell -d lv_LV,en_US Hunspell 1.2.14 + sagadīties - works properly. Test code (test.php): $encoding = "lv_LV.utf-8"; setlocale(LC_CTYPE, $encoding); // test putenv('LANG='.$encoding); // and another test $raw_response = shell_exec("LANG=$encoding; echo 'sagadījās' | hunspell -d lv_LV,en_US"); echo $raw_response; returns Hunspell 1.2.14 & sagad 5 0: tagad, sagad?ties, sagaudo, sagand?, sagar?o * *