1

I'm trying to get data from Python script:

import pymorphy2
import json
import sys

morph = pymorphy2.MorphAnalyzer()
butyavka = morph.parse(sys.argv[1])[0]
for item in butyavka.lexeme:
    print(item.word)

PHP code:

<?php
chdir('C:\\Users\Michael-PC\AppData\Local\Programs\Python\Python35-32');
$out;
passthru('python WordAnalizator.py "слово"', $out);
echo($out);
?>

If I use console, it make correct response, like:

enter image description here

But in PHP I have only first word:

enter image description here

Whats wrong?

Psidom
  • 209,562
  • 33
  • 339
  • 356
Michael
  • 15
  • 3

1 Answers1

0

This is obvious encoding problem (Russian letters become unreadable). So, try to set (i.e. change default) encoding in the PHP code, e.g. add to header usage of Unicode:

 header('Content-Type: text/html; charset=utf-8');

If charset=utf-8 does not help, try charset=windows-1251 instead.

UPDATE:

Do not forget to save your file (PHP code in UTF encoding for utf-8, or ANSI for windows-1251)

VolAnd
  • 6,367
  • 3
  • 25
  • 43