In my PHP script I'm executing a bash script with popen() and I output the response. But the response has a different encoding, and I don't know how to convert it.
I tried to convert it to utf8 but no results. Also tried to set the locale to nl_NL.utf8.
PHP function:
while (@ ob_end_flush()); // end all output buffers if any
$proc = popen("$cmd 2>&1 ; echo Exit status : $?", 'r');
$live_output = "";
$complete_output = "";
while (!feof($proc))
{
$live_output = fread($proc, 4096);
$complete_output = $complete_output . $live_output;
echo "$live_output";
@ flush();
}
pclose($proc);
Example response:
[2K[1A[2K[G
[2K[1A[2K[G⠋ load plugins
[2K[1A[2K[Gsuccess load plugins - 0.975 s
⠋ load plugins
This should be just:
success load plugins - 0.975 s
The ⠋ thing is a loader which is moving. Could that be the problem? Or are these characters the colorcode of the line?