I have a Python file I'm calling with PHP's exec
function. Python then outputs a string (apparently Unicode, based on using isinstance
), which is echoed by PHP. The problem I'm running into is that if my string has any special characters in it (like the degree symbol), it won't output. I'm sure I need to do something to fiddle with the encoding, but I'm not really sure what to do, and why.
EDIT: To get an idea of how I am calling exec
, please see the following code snippet:
$tables = shell_exec('/s/python-2.6.2/bin/python2.6 getWikitables.py '.$title);
Python properly outputs the string when I call getWikitables.py
by itself.
EDIT: It definitely seems to be something either on the Python end, or in transmitting the results. When I run strlen
on the returned values in PHP, I get 0. Can exec
only accept a certain type of encoding?
On php you can use methods like utf8_encode()
or utf8_decode()
to solve your problem.