Can't set correct encoding to outptut text buffer of the console process at russian windows 10. Please help with it. Need to convert console output into UTF-8 encoding and output in browser.
I'm tried different encodings:
- utf-16 -> utf-8
- ascii -> utf-8
- windows-1251 -> utf-8
- windows-1252 -> utf-8
But no luck :(
It's output only english characters and numbers. No russian symbols
<?php
header('Content-Type: text/html; charset=utf-8');
$cmd = "ping mail.ru";
execAndOutput($cmd);
function execAndOutput($cmd){
$process = popen($cmd, 'r');
while($out = fgets($process, 2048)) {
$out = mb_convert_encoding($out, "utf-8", "windows-1251");
echo $out."<br>\n";
ob_flush();flush();
}
pclose($process);
} ?>
With encoding 1251 I've got this in output:
ЋЎ¬Ґ Ї ЄҐв ¬Ё б mail.ru [94.100.180.202] б 32 Ў ©в ¬Ё ¤ ле:
ЋвўҐв ®в 94.100.180.202: зЁб«® Ў ©в=32 ўаҐ¬п=118¬б TTL=49
ЋвўҐв ®в 94.100.180.202: зЁб«® Ў ©в=32 ўаҐ¬п=118¬б TTL=49
‘в вЁбвЁЄ Ping ¤«п 94.100.180.202:
Џ ЄҐв®ў: ®вЇа ў«Ґ® = 4, Ї®«г祮 = 4, Ї®вҐап® = 0
(0% Ї®вҐам)
ЏаЁЎ«Ё§ЁвҐ«м®Ґ ўаҐ¬п ЇаЁҐ¬ -ЇҐаҐ¤ зЁ ў ¬б:
ЊЁЁ¬ «м®Ґ = 118¬бҐЄ, Њ ЄбЁ¬ «м®Ґ = 120 ¬бҐЄ, ‘।ҐҐ = 118 ¬бҐЄ
Without any encoding convertion I've got this:
����� ����⠬� � mail.ru [94.100.180.200] � 32 ���⠬� ������:
�⢥� �� 94.100.180.200: � ����=32 �६�=113�� TTL=46
�⢥� �� 94.100.180.200: � ����=32 �६�=170�� TTL=46
����⨪� Ping ��� 94.100.180.200:
����⮢: ��ࠢ���� = 4, ����祭� = 4, ����ﭮ = 0
(0% �����)
�ਡ����⥫쭮� �६� �ਥ��-��।�� � ��:
�������쭮� = 109�ᥪ, ���ᨬ��쭮� = 170 �ᥪ, �।��� = 135 �ᥪ
Expected (copied from windows terminal):
Обмен пакетами с 127.0.0.1 по с 32 байтами данных:
Ответ от 127.0.0.1: число байт=32 время<1мс TTL=128
Ответ от 127.0.0.1: число байт=32 время<1мс TTL=128
Статистика Ping для 127.0.0.1:
Пакетов: отправлено = 4, получено = 4, потеряно = 0
(0% потерь)
Приблизительное время приема-передачи в мс:
Минимальное = 0мсек, Максимальное = 0 мсек, Среднее = 0 мсек
I'm want to get Russian symbols from console in browser.
$out = mb_convert_encoding($out, "UTF-8", "ISO-8859-5");- arkascha