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

4
  • 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). Commented May 10, 2013 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. Commented May 10, 2013 at 22:15
  • see: stackoverflow.com/questions/3224268/python-unicode-encode-error Commented May 10, 2013 at 22:18
  • i fixed it with adding export PYTHONIOENCODING=UTF-8; before command Commented May 10, 2013 at 23:56

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.