1

using command

$ret = shell_exec($command);

results in $ret being null when $command returns string containing non-ascii characters (papír), but it works when $command returns string without non-ascii characters

same happens when using exec or system

as $command i tried

'LANG=en_US.utf-8; python myapp.py '.escapeshellarg($in);
'python myapp.py '.escapeshellarg($in);

results obviously depends on $in, but it works when $in contains non-ascii characters and script returns only ascii characters, so problem is with output not input in my opinion

sluki
  • 524
  • 5
  • 15
  • 1
    i creat a file command: `#!/bin/bash STR="papír" echo $STR` then i run php -r "var_dump(shell_exec('./command 2>&1'));" which doesn't retrun null but (string(7) "papír "). NOTE `php -r "echo strlen( 'papír' );"` will give 6 (the number of bytes). – Bass Jobsen May 10 '13 at 21:39
  • all this works for me. After using it to test i found that myapp.py also fails when redirected to file. `myapp.py > out.txt` results in UnicodeEncodeError. – sluki May 10 '13 at 22:15
  • see: http://stackoverflow.com/questions/3224268/python-unicode-encode-error – Bass Jobsen May 10 '13 at 22:18
  • i fixed it with adding `export PYTHONIOENCODING=UTF-8;` before command – sluki May 10 '13 at 23:56

0 Answers0