title: Encoding php and python?
body: <p>I wrote code that sends a query from php to a python script(some variable) and the python script does some things and returns some str. But this string is not valid! It has many question marks. I know that this problem appears when the encoding is not valid, but all files I'm using have the format <code>utf-8</code>.</p>
  
  <p>My php file:</p>
  
  <pre><code>$search = $_POST["search"];
  $search = shell_exec('get.py ' . $search);
   print($search);
  </code></pre>
  
  <p>And as result I see this <code>������������</code>. Python script code:</p>
  
  <pre><code>import sys
  import pymorphy2
  
  
  morph = pymorphy2.MorphAnalyzer()
  
  word = sys.argv[1]
  
  word = morph.parse(word)[0]
  i = 0
  result = ""
  while i &lt; len(word):
      result = result + " " + word.make_agree_with_number(i).word
      i = i + 1
  print (result)
  </code></pre>
  
  <p>Some interesting things: all (2) files are in <code>utf-8</code>. In the python script I use coding <code>utf-8</code> and it is not help. In php I use the <code>iconv()</code> function to change encoding, and use the <code>mb_detect_encoding</code> function to detect what the encoding is now. It shows <code>utf-8</code>. Please help me to make my encoding valid! </p>
  
  <p>My version of python is <code>3.5</code>, and I use <code>.htaccess</code>.</p>