skip to Main Content

This works:

$csv = " b'xd0x9exd0xb4xd0xbdxd0xb0xd0xbaxd0xbe xd0xbexd0xb1xd0xb8xd0xb4xd0xbdxd0xbe xd0xb1xd1x83xd0xb4xd0xb5xd1x82 xd0xbfxd0xbexd1x82xd1x80xd0xb0xd1x82xd0xb8xd1x82xd1x8c xd0xbdxd0xb0 xd0xb4xd0xb5xd0xbbxd0xb0 xd0xb2xd1x80xd0xb5xd0xbcxd1x8f, xd0xbaxd0xbexd1x82xd0xbexd1x80xd0xbexd0xb5 xd0xbcxd0xbexd0xb3xd0xbbxd0xb8 xd0xb1xd1x8b xd0xbfxd1x80xd0xbexd0xb2xd0xb5xd1x81xd1x82xd0xb8 xd0xb1xd0xbexd0xbbxd0xb5xd0xb5 xd0xbfxd0xbbxd0xbexd0xb4xd0xbexd1x82xd0xb2xd0xbexd1x80xd0xbdxd0xbe.'";
$csv = mb_convert_encoding($csv,'UTF-8');

While this returns unconverted string:

$o = shell_exec('python3.6 /var/www/html/main.py'.'normal');
$contents = mb_convert_encoding($o,'UTF-8');
echo $contents

Python script returns same string. I tried strval() and unpack(), didn’t work.
Here is the result of “locale -a”:
here

Even if i put call to script in eval() it interprets string as data.

2

Answers


  1. Chosen as BEST ANSWER

    I put this in php script and i don't have to encode anything between scripts,it just works:

    putenv("PYTHONIOENCODING=utf-8");
    

  2. Try adding this line before calling shell_exec():

    putenv('LANG=en_US.UTF-8');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search