0

So, I tried to input cyrillic symbols to save them. I use fgets() function to get symbols (actually symfony console uses it). The problem is I can't prevent random corrupting of symbols when I get them. To simplify, I made the next code:

$i=0;
while ($i !== 100) {
    $i++;
    $str = fgets(STDIN, 4096);
    echo $str;
}
die;

I entered ТАйтл, Некоторый текст, Тайтл. Always on a first or second entering I got this wrong symbols. Example of wrong symbols: ðóððÉð╣Ðéð╗ (ТАйтл).

I tried to play with mb_convert_encoding, but generally, I always have UTF-8 encoding, so it's not about converting. But about in this case?

Many thanks for helping.

  • the problem is in your terminal encoding. can you do what's will be written in terminal - echo $LANG – myxaxa Jun 25 '19 at 12:15
  • It's empty. Linux version just in case: `Linux version 4.9.125-linuxkit (root@659b6d51c354) (gcc version 6.4.0 (Alpine 6.4.0) ) #1 SMP Fri Sep 7 08:20:28 UTC 2018` – Nikita_kharkov_ua Jun 26 '19 at 08:03
  • try this to check your terminal charset - https://stackoverflow.com/questions/5306153/how-to-get-terminals-character-encoding – myxaxa Jun 26 '19 at 08:29
  • and this is ther help - https://benjamin-schweizer.de/unix-terminals-surviving-the-encoding-hell.html :) good luck! – myxaxa Jun 26 '19 at 08:30

0 Answers0