J
J
JViktor2015-10-06 08:16:36
PHP
JViktor, 2015-10-06 08:16:36

php and python encoding?

Hello everyone, the bottom line is, there is a script written in php that sends a variable to the python script, the python processes and returns the changed string.
PHP:

$search = $_POST["search"];
$search = shell_exec('hh.py ' . $search);
print($search);

Python:
import sys
import pymorphy2
result = "дерево" 
print (result)

As a result, the output is question marks .... the fact is that both files are encoded in utf-8 without BOM, while I added the #!/usr/bin/env pythons header to the python in the IDE, it shows all the rules, the Russian string .. .but in php it returns question marks....
Are there any options how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rostislav Grigoriev, 2015-10-06
@crazyzubr

At the beginning of the script, write
In the script code
result = u"дерево"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question